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