summaryrefslogtreecommitdiff
path: root/Annex/Branch.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-03 14:48:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-03 14:48:46 -0400
commit753e26e5e39b0038a634cfc529e6e634f6ca9035 (patch)
tree4b8305c042521ee34d53442e742856afd5696231 /Annex/Branch.hs
parentceb32f6063f169853fe97aa303c4fa0316a7da31 (diff)
ensure that commitBranch is only called when the journal is locked
This is not strictly a requirement, since it does not actually update the journal. But it's a nice invariant to enforce.
Diffstat (limited to 'Annex/Branch.hs')
-rw-r--r--Annex/Branch.hs22
1 files changed, 10 insertions, 12 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs
index f7b7f049a..a3cb8aa72 100644
--- a/Annex/Branch.hs
+++ b/Annex/Branch.hs
@@ -168,7 +168,7 @@ updateTo pairs = do
else inRepo $ Git.Branch.fastForward fullname refs
if ff
then updateIndex branchref
- else commitBranch branchref merge_desc commitrefs
+ else commitBranch jl branchref merge_desc commitrefs
liftIO cleanjournal
{- Gets the content of a file, which may be in the journal, or in the index
@@ -213,7 +213,7 @@ commit :: String -> Annex ()
commit message = whenM journalDirty $ lockJournal $ \jl -> do
cleanjournal <- stageJournal jl
ref <- getBranch
- withIndex $ commitBranch ref message [fullname]
+ withIndex $ commitBranch jl ref message [fullname]
liftIO cleanjournal
{- Commits the staged changes in the index to the branch.
@@ -233,15 +233,13 @@ commit message = whenM journalDirty $ lockJournal $ \jl -> do
- The branchref value can have been obtained using getBranch at any
- previous point, though getting it a long time ago makes the race
- more likely to occur.
- -
- - Should be called only inside lockJournal.
-}
-commitBranch :: Git.Ref -> String -> [Git.Ref] -> Annex ()
-commitBranch branchref message parents = do
+commitBranch :: JournalLocked -> Git.Ref -> String -> [Git.Ref] -> Annex ()
+commitBranch jl branchref message parents = do
showStoringStateAction
- commitBranch' branchref message parents
-commitBranch' :: Git.Ref -> String -> [Git.Ref] -> Annex ()
-commitBranch' branchref message parents = do
+ commitBranch' jl branchref message parents
+commitBranch' :: JournalLocked -> Git.Ref -> String -> [Git.Ref] -> Annex ()
+commitBranch' jl branchref message parents = do
updateIndex branchref
committedref <- inRepo $ Git.Branch.commit message fullname parents
setIndexSha committedref
@@ -267,7 +265,7 @@ commitBranch' branchref message parents = do
- into the index, and recommit on top of the bad commit. -}
fixrace committedref lostrefs = do
mergeIndex lostrefs
- commitBranch committedref racemessage [committedref]
+ commitBranch jl committedref racemessage [committedref]
racemessage = message ++ " (recovery from race)"
@@ -444,7 +442,7 @@ performTransitions :: Transitions -> Bool -> [Ref] -> Annex ()
performTransitions ts neednewlocalbranch transitionedrefs = lockJournal $ \jl ->
performTransitionsLocked jl ts neednewlocalbranch transitionedrefs
performTransitionsLocked :: JournalLocked -> Transitions -> Bool -> [Ref] -> Annex ()
-performTransitionsLocked _jl ts neednewlocalbranch transitionedrefs = do
+performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do
-- For simplicity & speed, we're going to use the Annex.Queue to
-- update the git-annex branch, while it usually holds changes
-- for the head branch. Flush any such changes.
@@ -458,7 +456,7 @@ performTransitionsLocked _jl ts neednewlocalbranch transitionedrefs = do
setIndexSha committedref
else do
ref <- getBranch
- commitBranch ref message (nub $ fullname:transitionedrefs)
+ commitBranch jl ref message (nub $ fullname:transitionedrefs)
where
message
| neednewlocalbranch && null transitionedrefs = "new branch for transition " ++ tdesc