Avoid grafting in export tree objects that are missing
authorJoey Hess <joeyh@joeyh.name>
Fri, 7 Jun 2024 20:50:05 +0000 (16:50 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 7 Jun 2024 20:51:50 +0000 (16:51 -0400)
They could be missing due to an interrupted git-annex at just the wrong
time during a prior graft, after which the tree objects got garbage
collected.

Or they could be missing because of manual messing with the git-annex
branch, eg resetting it to back before the graft commit.

Sponsored-by: Dartmouth College's OpenNeuro project
Annex/Branch.hs
doc/bugs/annex_merge__breaks_git_repository__33__.mdwn
doc/bugs/annex_merge__breaks_git_repository__33__/comment_9_67dfc2b1444bd345f911ed779cb98bcc._comment [new file with mode: 0644]

index 2fb9e030def4e3968c3a0f5718b6bf997423237c..806eabb99a31bd1711c0b4101733c8499918dc64 100644 (file)
@@ -889,9 +889,13 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do
                return c
          where
                regraft [] c = pure c
-               regraft (et:ets) c = 
-                       prepRememberTreeish et graftpoint c
-                               >>= regraft ets
+               regraft (et:ets) c =
+                       -- Verify that the tree object exists.
+                       catObjectDetails et >>= \case
+                               Just _ ->
+                                       prepRememberTreeish et graftpoint c
+                                               >>= regraft ets
+                               Nothing -> regraft ets c
                graftpoint = asTopFilePath exportTreeGraftPoint
 
 checkBranchDifferences :: Git.Ref -> Annex ()
index c453f3b39c3f6c08e83706d67cf0d40717e96885..d4b5486fc1edcdea8b14d629b083e44ee53a54bf 100644 (file)
@@ -53,3 +53,4 @@ there are good and there are some bad days ;)
 [[!meta author=yoh]]
 [[!tag projects/openneuro]]
 
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/annex_merge__breaks_git_repository__33__/comment_9_67dfc2b1444bd345f911ed779cb98bcc._comment b/doc/bugs/annex_merge__breaks_git_repository__33__/comment_9_67dfc2b1444bd345f911ed779cb98bcc._comment
new file mode 100644 (file)
index 0000000..267e315
--- /dev/null
@@ -0,0 +1,16 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 9"""
+ date="2024-06-07T20:25:27Z"
+ content="""
+Note that at least in the case of ds002144, its git-annex branch does not
+contain grafts of the missing trees. The grafts only get created in the
+clone when dealing with a transition.
+
+So, it seems that to recover from the problem, at least in the case of this
+repository, it will be sufficient for git-annex to avoid regrafting trees
+if the object is missing.
+
+Done that, and so I suppose this bug can be closed. I'd be more satified if
+I knew how this repository was produced though.
+"""]]