aboutsummaryrefslogtreecommitdiff
path: root/Annex/GitOverlay.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-06-03 13:48:14 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-06-03 13:57:00 -0400
commit583b8394b3c8f02a096352c76c63580c117d4482 (patch)
treecab673f51709e8639736a2adc65ec18f40ee993a /Annex/GitOverlay.hs
parent667ba46d7fd2f12141cfc49bd339d3861e87f4ed (diff)
withAltRepo needs a separate queue of changes
The queue could potentially contain changes from before withAltRepo, and get flushed inside the call, which would apply the changes to the modified repo. Or, changes could be queued in withAltRepo that were intended to affect the modified repo, but don't get flushed until later. I don't know of any cases where either happens, but better safe than sorry. Note that this affect withIndexFile, which is used in git-annex branch updates. So, it potentially makes things slower. Should not be by much; the overhead consists only of querying the current queue a couple of times, and potentially flushing changes queued within withAltRepo earlier, that could have maybe been bundled with other later changes. Notice in particular that the existing queue is not flushed when calling withAltRepo. So eg when git annex add needs to stage files in the index, it will still bundle them together efficiently.
Diffstat (limited to 'Annex/GitOverlay.hs')
-rw-r--r--Annex/GitOverlay.hs19
1 files changed, 15 insertions, 4 deletions
diff --git a/Annex/GitOverlay.hs b/Annex/GitOverlay.hs
index 2193b7449..1b7ceb2e2 100644
--- a/Annex/GitOverlay.hs
+++ b/Annex/GitOverlay.hs
@@ -15,6 +15,7 @@ import Git.Types
import Git.Index
import Git.Env
import qualified Annex
+import qualified Annex.Queue
{- Runs an action using a different git index file. -}
withIndexFile :: FilePath -> Annex a -> Annex a
@@ -71,8 +72,18 @@ withAltRepo
withAltRepo modrepo unmodrepo a = do
g <- gitRepo
g' <- liftIO $ modrepo g
- r <- tryNonAsync $ do
- Annex.changeState $ \s -> s { Annex.repo = g' }
+ q <- Annex.Queue.get
+ v <- tryNonAsync $ do
+ Annex.changeState $ \s -> s
+ { Annex.repo = g'
+ -- Start a separate queue for any changes made
+ -- with the modified repo.
+ , Annex.repoqueue = Nothing
+ }
a
- Annex.changeState $ \s -> s { Annex.repo = unmodrepo g (Annex.repo s) }
- either E.throw return r
+ void $ tryNonAsync Annex.Queue.flush
+ Annex.changeState $ \s -> s
+ { Annex.repo = unmodrepo g (Annex.repo s)
+ , Annex.repoqueue = Just q
+ }
+ either E.throw return v