Avoid grafting in export tree objects that are missing

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
This commit is contained in:
Joey Hess 2024-06-07 16:50:05 -04:00
parent b32c4c2e98
commit 25a6ab6f11
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 24 additions and 3 deletions

View 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 ()