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
|
||||
(sha:[]) -> return $ Just $ update_index_line sha file
|
||||
(sha:shas) -> do
|
||||
origcontent <- L.lines <$> catObject h sha
|
||||
content <- map L.lines <$> mapM (catObject h) shas
|
||||
let newcontent = nub $ concat $ origcontent:content
|
||||
newsha <- if (newcontent == origcontent)
|
||||
then return sha
|
||||
else hashObject (L.unlines $ newcontent) repo
|
||||
newsha <- maybe (return sha) (hashObject repo . L.unlines) =<<
|
||||
unionmerge
|
||||
<$> (L.lines <$> catObject h sha)
|
||||
<*> (map L.lines <$> mapM (catObject h) shas)
|
||||
return $ Just $ update_index_line newsha file
|
||||
where
|
||||
[_colonmode, _bmode, asha, bsha, _status] = words info
|
||||
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. -}
|
||||
hashObject :: L.ByteString -> Repo -> IO Sha
|
||||
hashObject content repo = getSha subcmd $ do
|
||||
hashObject :: Repo -> L.ByteString -> IO Sha
|
||||
hashObject repo content = getSha subcmd $ do
|
||||
(h, s) <- pipeWriteRead (map Param params) content repo
|
||||
L.length s `seq` do
|
||||
forceSuccess h
|
||||
|
|
Loading…
Reference in a new issue