narrow window where HEAD is detached

Updating an adjusted branch can take a while when there are a lot of
files. HEAD was detached at the start, so if eg git-annex sync was
interrupted at the wrong point, there was a possibly wide window where
it would leave the repo with HEAD detached.

There's still a window, just much narrower. I don't know if it's
possible to close the window entirely. While git can clearly update
the currently checked out branch in eg git merge, it doesn't seem to
provide another way to do it.

Sponsored-by: Graham Spencer on Patreon
This commit is contained in:
Joey Hess 2023-06-07 11:10:54 -04:00
parent 5bc37c2de2
commit 64fc34b3da
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -254,6 +254,8 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
-- origbranch.
_ <- propigateAdjustedCommits' origbranch adj commitlck
b <- adjustBranch adj origbranch
origheadfile <- inRepo $ readFileStrict . Git.Ref.headFile
-- Git normally won't do anything when asked to check
@ -268,7 +270,6 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
return (Just newheadfile)
_ -> return Nothing
b <- adjustBranch adj origbranch
return (b, origheadfile, newheadfile)
-- Make git checkout quiet to avoid warnings about