diff options
author | 2011-12-11 21:40:36 -0400 | |
---|---|---|
committer | 2011-12-11 21:46:21 -0400 | |
commit | 29b88ad657b4d84e84bdc366617d765726e29bb0 (patch) | |
tree | 7b9ed11f94609a6a25ef341be1d58940df967f1c /Annex | |
parent | c4c965d602687a6277d43ae003c12dc4c132ba28 (diff) |
avoid redundant call to updateIndex
commitBranch calls updateIndex
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Branch.hs | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs index 0ac419994..3da8bb198 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -203,38 +203,42 @@ commit message = whenM journalDirty $ lockJournal $ do - (It would be cleaner to handle the merge by updating the journal, not the - index, with changes from the branches.) - - - The index is always updated using a union merge, as that's the most - - efficient way to update it. However, if the branch can be - - fast-forwarded, that is then done, rather than adding an unnecessary - - commit to it. + - The branch is fast-forwarded if possible, otherwise a merge commit is + - made. -} update :: Annex () update = onceonly $ do - -- ensure branch exists, and index is up-to-date + -- ensure branch exists create - _ <- updateIndex -- check what needs updating before taking the lock dirty <- journalDirty c <- filterM (changedBranch name . snd) =<< siblingBranches let (refs, branches) = unzip c - unless (not dirty && null refs) $ withIndex $ lockJournal $ do - when dirty stageJournalFiles - let merge_desc = if null branches - then "update" - else "merging " ++ - unwords (map Git.refDescribe branches) ++ - " into " ++ show name - unless (null branches) $ do - showSideAction merge_desc - mergeIndex branches - ff <- if dirty then return False else tryFastForwardTo refs - unless ff $ commitBranch merge_desc (nub $ fullname:refs) - invalidateCache + if (not dirty && null refs) + then simpleupdate + else withIndex $ lockJournal $ do + when dirty stageJournalFiles + let merge_desc = if null branches + then "update" + else "merging " ++ + unwords (map Git.refDescribe branches) ++ + " into " ++ show name + unless (null branches) $ do + showSideAction merge_desc + mergeIndex branches + ff <- if dirty then return False else tryFastForwardTo refs + if ff + then simpleupdate + else commitBranch merge_desc (nub $ fullname:refs) + invalidateCache where onceonly a = unlessM (branchUpdated <$> getState) $ do r <- a disableUpdate return r + simpleupdate = do + _ <- updateIndex + return () {- Checks if the second branch has any commits not present on the first - branch. -} |