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.
This commit is contained in:
Joey Hess 2016-04-04 13:17:24 -04:00
parent c7b06b879b
commit c3e0859846
Failed to extract signature
7 changed files with 54 additions and 43 deletions

View file

@ -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. -}

View file

@ -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