sync: Fix bug in adjusted branch merging that could cause recently added files to...
authorJoey Hess <joeyh@joeyh.name>
Mon, 10 Oct 2016 19:00:45 +0000 (15:00 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 10 Oct 2016 19:00:45 +0000 (15:00 -0400)
The modification flag was not being set when making modifications deep
in a tree, so parent trees were not updated to contain the modified tree.

Seems to have exposed another bug where the wrong filename gets grafted in.

This commit was sponsored by Brock Spratlen on Patreon.

CHANGELOG
Git/Tree.hs
doc/bugs/sync_in_adjusted_branch_deleted_recently_added_files.mdwn

index dd9b2cba7f94213445512fed32244e7afe168787..6188fc0debaf672eda261a7930c2eb17adc048cc 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,8 @@ git-annex (6.20160924) UNRELEASED; urgency=medium
   * When auto-upgrading a v3 remote, avoid upgrading to version 6,
     instead keep it at version 5.
   * Support using v3 repositories without upgrading them to v5.
+  * sync: Fix bug in adjusted branch merging that could cause recently
+    added files to be lost when updating the adjusted branch.
 
  -- Joey Hess <id@joeyh.name>  Mon, 26 Sep 2016 16:46:19 -0400
 
index cfd5b910d829b4580c1a05bfa40d2af181482c44..65c3d713a4a9f77a6362668ca023d786cdc07881 100644 (file)
@@ -184,10 +184,11 @@ adjustTree adjusttreeitem addtreeitems removefiles r repo =
                        Just TreeObject -> do
                                (sl, modified, is') <- go h False [] (beneathSubTree i) is
                                sl' <- adjustlist h (inTree i) (beneathSubTree i) sl
-                               subtree <- if modified || sl' /= sl
+                               let slmodified = sl' /= sl
+                               subtree <- if modified || slmodified
                                        then liftIO $ recordSubTree h $ NewSubTree (LsTree.file i) sl'
                                        else return $ RecordedSubTree (LsTree.file i) (LsTree.sha i) [] 
-                               let !modified' = modified || wasmodified
+                               let !modified' = modified || slmodified || wasmodified
                                go h modified' (subtree : c) intree is'
                        _ -> error ("unexpected object type \"" ++ LsTree.typeobj i ++ "\"")
                | otherwise = return (c, wasmodified, i:is)
index 8c4425f8b0cfed4cc809b36c24dc61aae67e6fac..ce271d8ddcce1b53a0abb7cb1d09c744cdf42b76 100644 (file)
@@ -57,4 +57,24 @@ addtreeitems are in a deep subdirectory, it seems to not be adding them
 into the tree. This happens in simpler test cases, so something about
 this particular tree is breaking the code.
 
+----
+
+Ok, think I found the bug. In Git.Tree.adjustTree, it grafts in the new
+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.
+
+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
+that git thinks those files were renamed:
+
+        rename 2016/xxx xxx und yyy/{ => 2016/xxx xxx und yyy}/zzz/P1230949.JPG (100%)
+
+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.
+
 --[[Joey]]