refactor
This commit is contained in:
parent
b9ac585454
commit
0cbab5de65
1 changed files with 12 additions and 8 deletions
|
@ -105,20 +105,24 @@ mergeFile info file h repo = case filter (/= nullsha) [Ref asha, Ref bsha] of
|
||||||
[] -> return Nothing
|
[] -> return Nothing
|
||||||
(sha:[]) -> return $ Just $ update_index_line sha file
|
(sha:[]) -> return $ Just $ update_index_line sha file
|
||||||
(sha:shas) -> do
|
(sha:shas) -> do
|
||||||
origcontent <- L.lines <$> catObject h sha
|
newsha <- maybe (return sha) (hashObject repo . L.unlines) =<<
|
||||||
content <- map L.lines <$> mapM (catObject h) shas
|
unionmerge
|
||||||
let newcontent = nub $ concat $ origcontent:content
|
<$> (L.lines <$> catObject h sha)
|
||||||
newsha <- if (newcontent == origcontent)
|
<*> (map L.lines <$> mapM (catObject h) shas)
|
||||||
then return sha
|
|
||||||
else hashObject (L.unlines $ newcontent) repo
|
|
||||||
return $ Just $ update_index_line newsha file
|
return $ Just $ update_index_line newsha file
|
||||||
where
|
where
|
||||||
[_colonmode, _bmode, asha, bsha, _status] = words info
|
[_colonmode, _bmode, asha, bsha, _status] = words info
|
||||||
nullsha = Ref $ replicate shaSize '0'
|
nullsha = Ref $ replicate shaSize '0'
|
||||||
|
|
||||||
|
unionmerge origcontent content
|
||||||
|
| newcontent == origcontent = Nothing
|
||||||
|
| otherwise = Just newcontent
|
||||||
|
where
|
||||||
|
newcontent = nub $ concat $ origcontent:content
|
||||||
|
|
||||||
{- Injects some content into git, returning its Sha. -}
|
{- Injects some content into git, returning its Sha. -}
|
||||||
hashObject :: L.ByteString -> Repo -> IO Sha
|
hashObject :: Repo -> L.ByteString -> IO Sha
|
||||||
hashObject content repo = getSha subcmd $ do
|
hashObject repo content = getSha subcmd $ do
|
||||||
(h, s) <- pipeWriteRead (map Param params) content repo
|
(h, s) <- pipeWriteRead (map Param params) content repo
|
||||||
L.length s `seq` do
|
L.length s `seq` do
|
||||||
forceSuccess h
|
forceSuccess h
|
||||||
|
|
Loading…
Reference in a new issue