fix adjusted branch update breakage

Introduced recently in commit 64fc34b3da.

adjustBranch changes the sha that is recorded for the current branch
(eg the adjusted branch). So, have to get the original sha before
calling it.

Sponsored-by: Jack Hill on Patreon
This commit is contained in:
Joey Hess 2023-06-08 13:33:58 -04:00
parent 7888702955
commit 637f19bebb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -254,18 +254,19 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
-- origbranch.
_ <- propigateAdjustedCommits' origbranch adj commitlck
b <- adjustBranch adj origbranch
origheadfile <- inRepo $ readFileStrict . Git.Ref.headFile
origheadsha <- inRepo (Git.Ref.sha currbranch)
b <- adjustBranch adj origbranch
-- Git normally won't do anything when asked to check
-- out the currently checked out branch, even when its
-- ref has changed. Work around this by writing a raw
-- sha to .git/HEAD.
newheadfile <- inRepo (Git.Ref.sha currbranch) >>= \case
Just headsha -> do
newheadfile <- case origheadsha of
Just s -> do
inRepo $ \r -> do
let newheadfile = fromRef headsha
let newheadfile = fromRef s
writeFile (Git.Ref.headFile r) newheadfile
return (Just newheadfile)
_ -> return Nothing