summaryrefslogtreecommitdiff
path: root/Git/UnionMerge.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-08 00:29:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-08 00:29:39 -0400
commitd45a9a7831a567c548f2552e1470d72f1966fffd (patch)
tree172a41852cdc055f11606dbe5b68f7d0a7f91bc5 /Git/UnionMerge.hs
parent7d78cbf97ca9d5a579f05b4ba735be69bafdef97 (diff)
refactor and function name cleanup
(oops, I had a calcMerge and a calc_merge!)
Diffstat (limited to 'Git/UnionMerge.hs')
-rw-r--r--Git/UnionMerge.hs43
1 files changed, 22 insertions, 21 deletions
diff --git a/Git/UnionMerge.hs b/Git/UnionMerge.hs
index d38bdfe22..0987f9131 100644
--- a/Git/UnionMerge.hs
+++ b/Git/UnionMerge.hs
@@ -7,7 +7,7 @@
module Git.UnionMerge (
merge,
- merge_index
+ mergeIndex
) where
import qualified Data.Text.Lazy as L
@@ -32,40 +32,40 @@ import Git.FilePath
merge :: Ref -> Ref -> Repo -> IO ()
merge x y repo = do
h <- catFileStart repo
- stream_update_index repo
- [ ls_tree x repo
- , merge_trees x y h repo
+ streamUpdateIndex repo
+ [ lsTree x repo
+ , mergeTrees x y h repo
]
catFileStop h
-{- Merges a list of branches into the index. Previously staged changed in
+{- Merges a list of branches into the index. Previously staged changes in
- the index are preserved (and participate in the merge). -}
-merge_index :: CatFileHandle -> Repo -> [Ref] -> IO ()
-merge_index h repo bs =
- stream_update_index repo $ map (\b -> merge_tree_index b h repo) bs
+mergeIndex :: CatFileHandle -> Repo -> [Ref] -> IO ()
+mergeIndex h repo bs =
+ streamUpdateIndex repo $ map (\b -> mergeTreeIndex b h repo) bs
{- For merging two trees. -}
-merge_trees :: Ref -> Ref -> CatFileHandle -> Repo -> Streamer
-merge_trees (Ref x) (Ref y) h = calc_merge h $ "diff-tree":diff_opts ++ [x, y]
+mergeTrees :: Ref -> Ref -> CatFileHandle -> Repo -> Streamer
+mergeTrees (Ref x) (Ref y) h = doMerge h $ "diff-tree":diffOpts ++ [x, y]
{- For merging a single tree into the index. -}
-merge_tree_index :: Ref -> CatFileHandle -> Repo -> Streamer
-merge_tree_index (Ref x) h = calc_merge h $
- "diff-index" : diff_opts ++ ["--cached", x]
+mergeTreeIndex :: Ref -> CatFileHandle -> Repo -> Streamer
+mergeTreeIndex (Ref x) h = doMerge h $
+ "diff-index" : diffOpts ++ ["--cached", x]
-diff_opts :: [String]
-diff_opts = ["--raw", "-z", "-r", "--no-renames", "-l0"]
+diffOpts :: [String]
+diffOpts = ["--raw", "-z", "-r", "--no-renames", "-l0"]
-{- Calculates how to perform a merge, using git to get a raw diff,
- - and generating update-index input. -}
-calc_merge :: CatFileHandle -> [String] -> Repo -> Streamer
-calc_merge ch differ repo streamer = gendiff >>= go
+{- Streams update-index changes to perform a merge,
+ - using git to get a raw diff. -}
+doMerge :: CatFileHandle -> [String] -> Repo -> Streamer
+doMerge ch differ repo streamer = gendiff >>= go
where
gendiff = pipeNullSplit (map Param differ) repo
go [] = noop
go (info:file:rest) = mergeFile info file ch repo >>=
maybe (go rest) (\l -> streamer l >> go rest)
- go (_:[]) = error "calc_merge parse error"
+ go (_:[]) = error $ "parse error " ++ show differ
{- Given an info line from a git raw diff, and the filename, generates
- a line suitable for update-index that union merges the two sides of the
@@ -81,7 +81,8 @@ mergeFile info file h repo = case filter (/= nullSha) [Ref asha, Ref bsha] of
[_colonmode, _bmode, asha, bsha, _status] = words info
getcontents s = map L.unpack . L.lines .
L.decodeUtf8 <$> catObject h s
- use sha = return $ Just $ update_index_line sha FileBlob $ asTopFilePath file
+ use sha = return $ Just $
+ updateIndexLine sha FileBlob $ asTopFilePath file
{- Calculates a union merge between a list of refs, with contents.
-