summaryrefslogtreecommitdiff
path: root/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-06-30 13:32:47 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-06-30 13:32:47 -0400
commit896726cde425f6c74273b35cde30c1909551ff66 (patch)
tree39f5c3f7636b53af79625866d845e50897d8fd1c /Git.hs
parentf0497312a77d59f24c8273245ac324b02bb1eb13 (diff)
rename GitUnionMerge to Git.UnionMerge
Also, moved commit function into Git proper, it's not union merge specific.
Diffstat (limited to 'Git.hs')
-rw-r--r--Git.hs14
1 files changed, 14 insertions, 0 deletions
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]