summaryrefslogtreecommitdiff
path: root/Test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-04 01:41:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-04 01:41:00 -0400
commit0ba6b3aa7d3a7528ba95ffbae7df6634adbed9b6 (patch)
tree847c46b1f192e49e09bae113eb0e81cd784b3c26 /Test.hs
parent7ae14619cd4466fbb17ef1318821a6fba41c28b6 (diff)
add test cases for the new direct mode merge bug
Diffstat (limited to 'Test.hs')
-rw-r--r--Test.hs52
1 files changed, 50 insertions, 2 deletions
diff --git a/Test.hs b/Test.hs
index a93d9e4c9..af44ade08 100644
--- a/Test.hs
+++ b/Test.hs
@@ -198,8 +198,9 @@ unitTests note getenv = testGroup ("Unit Tests " ++ note)
, check "sync" test_sync
, check "union merge regression" test_union_merge_regression
, check "conflict resolution" test_conflict_resolution_movein_bug
- , check "conflict_resolution (mixed directory and file)" test_mixed_conflict_resolution
- , check "conflict_resolution (mixed directory and file) 2" test_mixed_conflict_resolution2
+ , check "conflict resolution (mixed directory and file)" test_mixed_conflict_resolution
+ , check "conflict resolution (mixed directory and file) 2" test_mixed_conflict_resolution2
+ , check "conflict resolution (uncommitted local file)" test_uncommitted_conflict_resolution
, check "map" test_map
, check "uninit" test_uninit
, check "uninit (in git-annex branch)" test_uninit_inbranch
@@ -840,6 +841,53 @@ test_mixed_conflict_resolution env = do
any (variantprefix `isPrefixOf`) l
@? (what ++ " conflictor file missing in: " ++ show l )
+{- Check merge conflict resolution when there is a local file,
+ - that is not staged or committed, that conflicts with what's being added
+ - from the remmote.
+ -
+ - Case 1: Remote adds file named conflictor; local has a file named
+ - conflictor.
+ -
+ - Case 2: Remote adds conflictor/file; local has a file named conflictor.
+ -}
+test_uncommitted_conflict_resolution :: TestEnv -> Assertion
+test_uncommitted_conflict_resolution env = do
+ check conflictor
+ check (conflictor </> "file")
+ where
+ check remoteconflictor = withtmpclonerepo env False $ \r1 ->
+ withtmpclonerepo env False $ \r2 -> do
+ indir env r1 $ do
+ disconnectOrigin
+ createDirectoryIfMissing True (parentDir remoteconflictor)
+ writeFile remoteconflictor annexedcontent
+ git_annex env "add" [conflictor] @? "add remoteconflicter failed"
+ git_annex env "sync" [] @? "sync failed in r1"
+ indir env r2 $ do
+ disconnectOrigin
+ writeFile conflictor localcontent
+ pair env r1 r2
+ indir env r2 $ ifM (annexeval Config.isDirect)
+ ( do
+ git_annex env "sync" [] @? "sync failed"
+ let local = conflictor ++ localprefix
+ doesFileExist local @? (local ++ " missing after merge")
+ s <- readFile local
+ s == localcontent @? (local ++ " has wrong content: " ++ s)
+ git_annex env "get" [conflictor] @? "get failed"
+ doesFileExist remoteconflictor @? (remoteconflictor ++ " missing after merge")
+ s' <- readFile remoteconflictor
+ s' == annexedcontent @? (remoteconflictor ++ " has wrong content: " ++ s)
+ -- this case is intentionally not handled
+ -- in indirect mode, since the user
+ -- can recover on their own easily
+ , not <$> git_annex env "sync" [] @? "sync failed to fail"
+ )
+ conflictor = "conflictor"
+ localprefix = ".variant-local"
+ localcontent = "local"
+ annexedcontent = "annexed"
+
{-
- During conflict resolution, one of the annexed files in git is
- accidentially converted from a symlink to a regular file.