diff options
Diffstat (limited to 'Git')
-rw-r--r-- | Git/Branch.hs | 14 | ||||
-rw-r--r-- | Git/Ref.hs | 6 |
2 files changed, 13 insertions, 7 deletions
diff --git a/Git/Branch.hs b/Git/Branch.hs index 6258939cb..76097fe13 100644 --- a/Git/Branch.hs +++ b/Git/Branch.hs @@ -184,21 +184,21 @@ commitTree commitmode message parentrefs tree repo = forcePush :: String -> String forcePush b = "+" ++ b -{- Updates a branch (or other ref) to a new Sha. -} -update :: String -> Branch -> Sha -> Repo -> IO () -update message branch sha = run +{- Updates a branch (or other ref) to a new Sha or branch Ref. -} +update :: String -> Branch -> Ref -> Repo -> IO () +update message branch r = run [ Param "update-ref" , Param "-m" , Param message , Param $ fromRef branch - , Param $ fromRef sha + , Param $ fromRef r ] -update' :: Branch -> Sha -> Repo -> IO () -update' branch sha = run +update' :: Branch -> Ref -> Repo -> IO () +update' branch r = run [ Param "update-ref" , Param $ fromRef branch - , Param $ fromRef sha + , Param $ fromRef r ] {- Checks out a branch, creating it if necessary. -} diff --git a/Git/Ref.hs b/Git/Ref.hs index 7f21b0ab8..6cd56271f 100644 --- a/Git/Ref.hs +++ b/Git/Ref.hs @@ -18,6 +18,12 @@ import Data.Char (chr) headRef :: Ref headRef = Ref "HEAD" +headFile :: Repo -> FilePath +headFile r = localGitDir r </> "HEAD" + +setHeadRef :: Ref -> Repo -> IO () +setHeadRef ref r = writeFile (headFile r) ("ref: " ++ fromRef ref) + {- Converts a fully qualified git ref into a user-visible string. -} describe :: Ref -> String describe = fromRef . base |