aboutsummaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-04-04 13:17:24 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-04-04 13:17:24 -0400
commit9b3a2e6c91afb886f1743769a5100fcf056d6ea7 (patch)
tree282232aee8154832c631d9c7efc87062140051fe /Git
parentf312b66a5cfc99ca5f01a07755f645659e75564a (diff)
Upgrading a direct mode repository to v6 has changed to enter an adjusted unlocked branch.
This makes the direct mode to v6 upgrade able to be performed in one clone of a repository without affecting other clones, which can continue using v5 and direct mode.
Diffstat (limited to 'Git')
-rw-r--r--Git/Branch.hs14
-rw-r--r--Git/Ref.hs6
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