readFileStrict to avoid laziness bug
authorJoey Hess <joeyh@joeyh.name>
Tue, 4 Apr 2023 18:25:01 +0000 (14:25 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 4 Apr 2023 18:25:01 +0000 (14:25 -0400)
Fix laziness bug introduced in last release that breaks use of
--unlock-present and --hide-missing adjusted branches.

Since there is a writeFile of the same file immediately after readFile, it
may still have the file open for read (or may have happened to read it
already and closed it).

I was not able to reproduce the problem in brief testing, but this seems
obvious.

Sponsored-by: Luke Shumaker on Patreona
Annex/AdjustedBranch.hs
CHANGELOG

index 5cef6ec29cf00be3d4efca466a7aa2f594069ed9..66d633d699b73c38fd52b47a21658594aa257008 100644 (file)
@@ -253,8 +253,8 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
                        -- has that have not yet been propigated back to the
                        -- origbranch.
                        _ <- propigateAdjustedCommits' origbranch adj commitlck
-                               
-                       origheadfile <- inRepo $ readFile . Git.Ref.headFile
+                       
+                       origheadfile <- inRepo $ readFileStrict . Git.Ref.headFile
 
                        -- Git normally won't do anything when asked to check
                        -- out the currently checked out branch, even when its
@@ -279,7 +279,7 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
                unless ok $ case newheadfile of
                        Nothing -> noop
                        Just v -> preventCommits $ \_commitlck -> inRepo $ \r -> do
-                               v' <- readFile (Git.Ref.headFile r)
+                               v' <- readFileStrict (Git.Ref.headFile r)
                                when (v == v') $
                                        writeFile (Git.Ref.headFile r) origheadfile
 
index ff8ffdeb2ab3e8efd75519562c02012dbe3d2945..2304c747c3708aeb60d621de32273d5436eb4620 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,8 @@ git-annex (10.20230330) UNRELEASED; urgency=medium
   * git-annex.cabal: Prevent building with unix-compat 0.7 which
     removed System.PosixCompat.User.
   * Sped up sqlite inserts 2x when built with persistent 2.14.5.0
+  * Fix laziness bug introduced in last release that breaks use
+    of --unlock-present and --hide-missing adjusted branches.
 
  -- Joey Hess <id@joeyh.name>  Fri, 31 Mar 2023 12:48:54 -0400