From cf34e59c8cd86db60549653eccea1aae2315bc64 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 5 Nov 2013 18:20:52 -0400 Subject: [PATCH] factor out update --- Git/Branch.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Git/Branch.hs b/Git/Branch.hs index 01d028f55f..7b560246ee 100644 --- a/Git/Branch.hs +++ b/Git/Branch.hs @@ -97,7 +97,7 @@ commit message branch parentrefs repo = do sha <- getSha "commit-tree" $ pipeWriteRead (map Param $ ["commit-tree", show tree] ++ ps) (Just $ flip hPutStr message) repo - run [Param "update-ref", Param $ show branch, Param $ show sha] repo + update branch sha repo return sha where ps = concatMap (\r -> ["-p", show r]) parentrefs @@ -105,3 +105,11 @@ commit message branch parentrefs repo = do {- A leading + makes git-push force pushing a branch. -} forcePush :: String -> String forcePush b = "+" ++ b + +{- Updates a branch (or other ref) to a new Sha. -} +update :: Branch -> Sha -> Repo -> IO () +update branch sha = run + [ Param "update-ref" + , Param $ show branch + , Param $ show sha + ]