diff options
author | Joey Hess <joey@kitenet.net> | 2013-10-23 12:58:01 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-10-23 13:00:45 -0400 |
commit | b77b0848ee28093b63e3ab0d1ea494e430ffe58b (patch) | |
tree | 7bcc235a07319bb4461373b5d0656ddc90aad357 /Annex | |
parent | fb2ccfd60ff09c1b1d03838d42eba3c65fd7fb27 (diff) |
repair command: add handling of git-annex branch and index
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Branch.hs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs index c704cef87..8192804a6 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -20,6 +20,7 @@ module Annex.Branch ( get, change, commit, + forceCommit, files, withIndex, performTransitions, @@ -168,7 +169,7 @@ updateTo pairs = do else inRepo $ Git.Branch.fastForward fullname refs if ff then updateIndex jl branchref - else commitBranch jl branchref merge_desc commitrefs + else commitIndex jl branchref merge_desc commitrefs liftIO cleanjournal {- Gets the content of a file, which may be in the journal, or in the index @@ -210,10 +211,15 @@ set = setJournalFile {- Stages the journal, and commits staged changes to the branch. -} commit :: String -> Annex () -commit message = whenM journalDirty $ lockJournal $ \jl -> do +commit = whenM journalDirty . forceCommit + +{- Commits the current index to the branch even without any journalleda + - changes. -} +forceCommit :: String -> Annex () +forceCommit message = lockJournal $ \jl -> do cleanjournal <- stageJournal jl ref <- getBranch - withIndex $ commitBranch jl ref message [fullname] + withIndex $ commitIndex jl ref message [fullname] liftIO cleanjournal {- Commits the staged changes in the index to the branch. @@ -234,12 +240,12 @@ commit message = whenM journalDirty $ lockJournal $ \jl -> do - previous point, though getting it a long time ago makes the race - more likely to occur. -} -commitBranch :: JournalLocked -> Git.Ref -> String -> [Git.Ref] -> Annex () -commitBranch jl branchref message parents = do +commitIndex :: JournalLocked -> Git.Ref -> String -> [Git.Ref] -> Annex () +commitIndex jl branchref message parents = do showStoringStateAction - commitBranch' jl branchref message parents -commitBranch' :: JournalLocked -> Git.Ref -> String -> [Git.Ref] -> Annex () -commitBranch' jl branchref message parents = do + commitIndex' jl branchref message parents +commitIndex' :: JournalLocked -> Git.Ref -> String -> [Git.Ref] -> Annex () +commitIndex' jl branchref message parents = do updateIndex jl branchref committedref <- inRepo $ Git.Branch.commit message fullname parents setIndexSha committedref @@ -265,7 +271,7 @@ commitBranch' jl branchref message parents = do - into the index, and recommit on top of the bad commit. -} fixrace committedref lostrefs = do mergeIndex jl lostrefs - commitBranch jl committedref racemessage [committedref] + commitIndex jl committedref racemessage [committedref] racemessage = message ++ " (recovery from race)" @@ -482,7 +488,7 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do setIndexSha committedref else do ref <- getBranch - commitBranch jl ref message (nub $ fullname:transitionedrefs) + commitIndex jl ref message (nub $ fullname:transitionedrefs) where message | neednewlocalbranch && null transitionedrefs = "new branch for transition " ++ tdesc |