avoid merging multiple branches that point to the same tree
avoids git warning "error: duplicate parent xxx ignored"
This commit is contained in:
parent
3acdba3995
commit
44fc358885
1 changed files with 13 additions and 10 deletions
|
@ -126,7 +126,8 @@ update = do
|
||||||
unless (branchUpdated state) $ do
|
unless (branchUpdated state) $ do
|
||||||
-- check what needs updating before taking the lock
|
-- check what needs updating before taking the lock
|
||||||
fs <- getJournalFiles
|
fs <- getJournalFiles
|
||||||
refs <- filterM checkref =<< siblingBranches
|
c <- filterM changedbranch =<< siblingBranches
|
||||||
|
let (refs, branches) = unzip c
|
||||||
unless (null fs && null refs) $ withIndex $ lockJournal $ do
|
unless (null fs && null refs) $ withIndex $ lockJournal $ do
|
||||||
{- Before refs are merged into the index, it's
|
{- Before refs are merged into the index, it's
|
||||||
- important to first stage the journal into the
|
- important to first stage the journal into the
|
||||||
|
@ -140,9 +141,9 @@ update = do
|
||||||
-}
|
-}
|
||||||
unless (null fs) $ stageJournalFiles fs
|
unless (null fs) $ stageJournalFiles fs
|
||||||
g <- gitRepo
|
g <- gitRepo
|
||||||
unless (null refs) $ do
|
unless (null branches) $ do
|
||||||
showSideAction $ "merging " ++
|
showSideAction $ "merging " ++
|
||||||
(unwords $ map Git.refDescribe refs) ++
|
(unwords $ map Git.refDescribe branches) ++
|
||||||
" into " ++ name
|
" into " ++ name
|
||||||
{- Note: This merges the branches into the index.
|
{- Note: This merges the branches into the index.
|
||||||
- Any unstaged changes in the git-annex branch
|
- Any unstaged changes in the git-annex branch
|
||||||
|
@ -150,18 +151,18 @@ update = do
|
||||||
- documentation advises users not to directly
|
- documentation advises users not to directly
|
||||||
- modify the branch.
|
- modify the branch.
|
||||||
-}
|
-}
|
||||||
liftIO $ Git.UnionMerge.merge_index g refs
|
liftIO $ Git.UnionMerge.merge_index g branches
|
||||||
liftIO $ Git.commit g "update" fullname (fullname:refs)
|
liftIO $ Git.commit g "update" fullname (nub $ fullname:refs)
|
||||||
Annex.changeState $ \s -> s { Annex.branchstate = state { branchUpdated = True } }
|
Annex.changeState $ \s -> s { Annex.branchstate = state { branchUpdated = True } }
|
||||||
invalidateCache
|
invalidateCache
|
||||||
where
|
where
|
||||||
checkref ref = do
|
changedbranch (_, branch) = do
|
||||||
g <- gitRepo
|
g <- gitRepo
|
||||||
-- checking with log to see if there have been changes
|
-- checking with log to see if there have been changes
|
||||||
-- is less expensive than always merging
|
-- is less expensive than always merging
|
||||||
diffs <- liftIO $ Git.pipeRead g [
|
diffs <- liftIO $ Git.pipeRead g [
|
||||||
Param "log",
|
Param "log",
|
||||||
Param (name++".."++ref),
|
Param (name ++ ".." ++ branch),
|
||||||
Params "--oneline -n1"
|
Params "--oneline -n1"
|
||||||
]
|
]
|
||||||
return $ not $ L.null diffs
|
return $ not $ L.null diffs
|
||||||
|
@ -185,13 +186,15 @@ hasOrigin = refExists originname
|
||||||
hasSomeBranch :: Annex Bool
|
hasSomeBranch :: Annex Bool
|
||||||
hasSomeBranch = not . null <$> siblingBranches
|
hasSomeBranch = not . null <$> siblingBranches
|
||||||
|
|
||||||
{- List of all git-annex branches, including the main one and any
|
{- List of all git-annex (refs, branches), including the main one and any
|
||||||
- from remotes. -}
|
- from remotes. -}
|
||||||
siblingBranches :: Annex [String]
|
siblingBranches :: Annex [(String, String)]
|
||||||
siblingBranches = do
|
siblingBranches = do
|
||||||
g <- gitRepo
|
g <- gitRepo
|
||||||
r <- liftIO $ Git.pipeRead g [Param "show-ref", Param name]
|
r <- liftIO $ Git.pipeRead g [Param "show-ref", Param name]
|
||||||
return $ map (last . words . L.unpack) (L.lines r)
|
return $ map (pair . words . L.unpack) (L.lines r)
|
||||||
|
where
|
||||||
|
pair l = (head l, last l)
|
||||||
|
|
||||||
{- Applies a function to modifiy the content of a file. -}
|
{- Applies a function to modifiy the content of a file. -}
|
||||||
change :: FilePath -> (String -> String) -> Annex ()
|
change :: FilePath -> (String -> String) -> Annex ()
|
||||||
|
|
Loading…
Reference in a new issue