From 896726cde425f6c74273b35cde30c1909551ff66 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 30 Jun 2011 13:32:47 -0400 Subject: rename GitUnionMerge to Git.UnionMerge Also, moved commit function into Git proper, it's not union merge specific. --- Git.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Git.hs') diff --git a/Git.hs b/Git.hs index 2b0cdd06d..7005f24f5 100644 --- a/Git.hs +++ b/Git.hs @@ -56,6 +56,7 @@ module Git ( hashObject, getSha, shaSize, + commit, prop_idempotent_deencode ) where @@ -425,6 +426,19 @@ getSha subcommand a = do shaSize :: Int shaSize = 40 +{- Commits the index into the specified branch, + - with the specified parent refs. -} +commit :: Repo -> String -> String -> [String] -> IO () +commit g message newref parentrefs = do + tree <- getSha "write-tree" $ + pipeRead g [Param "write-tree"] + sha <- getSha "commit-tree" $ ignorehandle $ + pipeWriteRead g (map Param $ ["commit-tree", tree] ++ ps) message + run g "update-ref" [Param newref, Param sha] + where + ignorehandle a = return . snd =<< a + ps = concatMap (\r -> ["-p", r]) parentrefs + {- Reads null terminated output of a git command (as enabled by the -z - parameter), and splits it into a list of files/lines/whatever. -} pipeNullSplit :: Repo -> [CommandParam] -> IO [FilePath] -- cgit v1.2.3