add test case for sync_in_adjusted_branch_deleted_recently_added_files
authorJoey Hess <joeyh@joeyh.name>
Tue, 11 Oct 2016 18:22:49 +0000 (14:22 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 11 Oct 2016 18:22:49 +0000 (14:22 -0400)
This commit was sponsored by Denis Dzyubenko on Patreon.

Test.hs
doc/bugs/sync_in_adjusted_branch_deleted_recently_added_files.mdwn

diff --git a/Test.hs b/Test.hs
index cd7118fe407f1820e05510726b56b5152de3bb9b..abd26e4ea883cf5ac5a6742d4ef6827892219862 100644 (file)
--- a/Test.hs
+++ b/Test.hs
@@ -234,6 +234,7 @@ unitTests note = testGroup ("Unit Tests " ++ note)
        , testCase "sync" test_sync
        , testCase "union merge regression" test_union_merge_regression
        , testCase "adjusted branch merge regression" test_adjusted_branch_merge_regression
+       , testCase "adjusted branch subtree regression" test_adjusted_branch_subtree_regression
        , testCase "conflict resolution" test_conflict_resolution
        , testCase "conflict resolution (adjusted branch)" test_conflict_resolution_adjusted_branch
        , testCase "conflict resolution movein regression" test_conflict_resolution_movein_regression
@@ -1425,6 +1426,27 @@ test_adjusted_branch_merge_regression = whenM Annex.AdjustedBranch.isGitVersionS
                conflictor `elem` l
                        @? ("conflictor not present after merge in " ++ what)
 
+{- Regression test for a bug in adjusted branch syncing code, where adding
+ - a subtree to an existing tree lost files. -}
+test_adjusted_branch_subtree_regression :: Assertion
+test_adjusted_branch_subtree_regression = 
+       whenM Annex.AdjustedBranch.isGitVersionSupported $ 
+               withtmpclonerepo $ \r -> do
+                       indir r $ do
+                               disconnectOrigin
+                               git_annex "upgrade" [] @? "upgrade failed"
+                               git_annex "adjust" ["--unlock", "--force"] @? "adjust failed"
+                               createDirectoryIfMissing True "a/b/c"
+                               writeFile "a/b/c/d" "foo"
+                               git_annex "add" ["a/b/c"] @? "add a/b/c failed"
+                               git_annex "sync" [] @? "sync failed"
+                               createDirectoryIfMissing True "a/b/x"
+                               writeFile "a/b/x/y" "foo"
+                               git_annex "add" ["a/b/x"] @? "add a/b/x failed"
+                               git_annex "sync" [] @? "sync failed"
+                               boolSystem "git" [Param "checkout", Param "master"] @? "git checkout master failed"
+                               doesFileExist "a/b/x/y" @? ("a/b/x/y missing from master after adjusted branch sync")
+
 {- Set up repos as remotes of each other. -}
 pair :: FilePath -> FilePath -> Assertion
 pair r1 r2 = forM_ [r1, r2] $ \r -> indir r $ do
index ce271d8ddcce1b53a0abb7cb1d09c744cdf42b76..4681cbe4827ec45ac1a920a856c6cb764b56121e 100644 (file)
@@ -64,8 +64,7 @@ tree items, but it can forget that it needed to modify the tree, which
 prevents the change from propigating up from the subtree to the root, and
 so it gets left out of the reverse adjusted commit.
 
-I'm committing a fix, but this needs a test case. Leaving bug open for
-that.
+I'm committing a fix. 
 
 With the fix, when I git annex sync in felix's tree, the files that
 were getting wrongly deleted are added. The commit summary shows
@@ -77,4 +76,13 @@ This seems wrong. I think this is a separate bug that was hidden
 by the other one, it's grafting in files using their whole path,
 to a subtree that is itself part way down that path.
 
+---
+
+A simpler case of the both bugs is to have a file like a/b/c/d already
+committed and make a commit that adds a/b/x/y, without otherwise modifying
+that tree. On an adjusted branch, `git annex sync` makes a commit of a tree
+that does not include the new file. It may made a commit on top of it for
+the adjusted branch that adds the file back, but the file doesn't reach
+the master branch in this scenario.
+
 --[[Joey]]