summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-13 15:08:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-13 15:08:44 -0400
commit25b2cc4148e4cc8f7435cdbcf4b124cc317c1305 (patch)
tree51f22dc7c65bb38574c4682ec16ca7a552d96cf6
parent13fff71f2019ae098c3f8532ac2734cb1ab11498 (diff)
move commit to Git.Branch
-rw-r--r--Annex/Branch.hs4
-rw-r--r--Git.hs18
-rw-r--r--Git/Branch.hs17
3 files changed, 19 insertions, 20 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs
index f9fa6cbb3..a2ecd50a7 100644
--- a/Annex/Branch.hs
+++ b/Annex/Branch.hs
@@ -71,7 +71,7 @@ getBranch = maybe (hasOrigin >>= go >>= use) (return) =<< branchsha
fromMaybe (error $ "failed to create " ++ show name)
<$> branchsha
go False = withIndex' True $ do
- inRepo $ Git.commit "branch created" fullname []
+ inRepo $ Git.Branch.commit "branch created" fullname []
use sha = do
setIndexSha sha
return sha
@@ -190,7 +190,7 @@ commit message = whenM journalDirty $ lockJournal $ do
commitBranch :: Git.Ref -> String -> [Git.Ref] -> Annex ()
commitBranch branchref message parents = do
updateIndex branchref
- committedref <- inRepo $ Git.commit message fullname parents
+ committedref <- inRepo $ Git.Branch.commit message fullname parents
setIndexSha committedref
parentrefs <- commitparents <$> catObject committedref
when (racedetected branchref parentrefs) $
diff --git a/Git.hs b/Git.hs
index cb7cc19c2..36b83c65b 100644
--- a/Git.hs
+++ b/Git.hs
@@ -52,7 +52,6 @@ module Git (
useIndex,
getSha,
shaSize,
- commit,
assertLocal,
prop_idempotent_deencode
@@ -354,23 +353,6 @@ getSha subcommand a = do
shaSize :: Int
shaSize = 40
-{- Commits the index into the specified branch (or other ref),
- - with the specified parent refs, and returns the committed sha -}
-commit :: String -> Branch -> [Ref] -> Repo -> IO Sha
-commit message branch parentrefs repo = do
- tree <- getSha "write-tree" $ asString $
- pipeRead [Param "write-tree"] repo
- sha <- getSha "commit-tree" $ asString $
- ignorehandle $ pipeWriteRead
- (map Param $ ["commit-tree", show tree] ++ ps)
- (L.pack message) repo
- run "update-ref" [Param $ show branch, Param $ show sha] repo
- return sha
- where
- ignorehandle a = snd <$> a
- asString a = L.unpack <$> a
- ps = concatMap (\r -> ["-p", show r]) parentrefs
-
{- Checks if a string from git config is a true value. -}
configTrue :: String -> Bool
configTrue s = map toLower s == "true"
diff --git a/Git/Branch.hs b/Git/Branch.hs
index e69e96f28..8b0d1e5af 100644
--- a/Git/Branch.hs
+++ b/Git/Branch.hs
@@ -58,3 +58,20 @@ fastForward branch (first:rest) repo = do
(True, False) -> findbest r rs -- better
(False, True) -> findbest c rs -- worse
(False, False) -> findbest c rs -- same
+
+{- Commits the index into the specified branch (or other ref),
+ - with the specified parent refs, and returns the committed sha -}
+commit :: String -> Branch -> [Ref] -> Repo -> IO Sha
+commit message branch parentrefs repo = do
+ tree <- getSha "write-tree" $ asString $
+ pipeRead [Param "write-tree"] repo
+ sha <- getSha "commit-tree" $ asString $
+ ignorehandle $ pipeWriteRead
+ (map Param $ ["commit-tree", show tree] ++ ps)
+ (L.pack message) repo
+ run "update-ref" [Param $ show branch, Param $ show sha] repo
+ return sha
+ where
+ ignorehandle a = snd <$> a
+ asString a = L.unpack <$> a
+ ps = concatMap (\r -> ["-p", show r]) parentrefs