avoid redundant call to updateIndex
commitBranch calls updateIndex
This commit is contained in:
parent
c4c965d602
commit
29b88ad657
1 changed files with 23 additions and 19 deletions
|
@ -203,21 +203,20 @@ commit message = whenM journalDirty $ lockJournal $ do
|
||||||
- (It would be cleaner to handle the merge by updating the journal, not the
|
- (It would be cleaner to handle the merge by updating the journal, not the
|
||||||
- index, with changes from the branches.)
|
- index, with changes from the branches.)
|
||||||
-
|
-
|
||||||
- The index is always updated using a union merge, as that's the most
|
- The branch is fast-forwarded if possible, otherwise a merge commit is
|
||||||
- efficient way to update it. However, if the branch can be
|
- made.
|
||||||
- fast-forwarded, that is then done, rather than adding an unnecessary
|
|
||||||
- commit to it.
|
|
||||||
-}
|
-}
|
||||||
update :: Annex ()
|
update :: Annex ()
|
||||||
update = onceonly $ do
|
update = onceonly $ do
|
||||||
-- ensure branch exists, and index is up-to-date
|
-- ensure branch exists
|
||||||
create
|
create
|
||||||
_ <- updateIndex
|
|
||||||
-- check what needs updating before taking the lock
|
-- check what needs updating before taking the lock
|
||||||
dirty <- journalDirty
|
dirty <- journalDirty
|
||||||
c <- filterM (changedBranch name . snd) =<< siblingBranches
|
c <- filterM (changedBranch name . snd) =<< siblingBranches
|
||||||
let (refs, branches) = unzip c
|
let (refs, branches) = unzip c
|
||||||
unless (not dirty && null refs) $ withIndex $ lockJournal $ do
|
if (not dirty && null refs)
|
||||||
|
then simpleupdate
|
||||||
|
else withIndex $ lockJournal $ do
|
||||||
when dirty stageJournalFiles
|
when dirty stageJournalFiles
|
||||||
let merge_desc = if null branches
|
let merge_desc = if null branches
|
||||||
then "update"
|
then "update"
|
||||||
|
@ -228,13 +227,18 @@ update = onceonly $ do
|
||||||
showSideAction merge_desc
|
showSideAction merge_desc
|
||||||
mergeIndex branches
|
mergeIndex branches
|
||||||
ff <- if dirty then return False else tryFastForwardTo refs
|
ff <- if dirty then return False else tryFastForwardTo refs
|
||||||
unless ff $ commitBranch merge_desc (nub $ fullname:refs)
|
if ff
|
||||||
|
then simpleupdate
|
||||||
|
else commitBranch merge_desc (nub $ fullname:refs)
|
||||||
invalidateCache
|
invalidateCache
|
||||||
where
|
where
|
||||||
onceonly a = unlessM (branchUpdated <$> getState) $ do
|
onceonly a = unlessM (branchUpdated <$> getState) $ do
|
||||||
r <- a
|
r <- a
|
||||||
disableUpdate
|
disableUpdate
|
||||||
return r
|
return r
|
||||||
|
simpleupdate = do
|
||||||
|
_ <- updateIndex
|
||||||
|
return ()
|
||||||
|
|
||||||
{- Checks if the second branch has any commits not present on the first
|
{- Checks if the second branch has any commits not present on the first
|
||||||
- branch. -}
|
- branch. -}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue