diff options
author | Joey Hess <joey@kitenet.net> | 2011-12-30 16:50:05 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-12-30 17:01:03 -0400 |
commit | 556618a3ec132a8270a48670243674bec563cb6b (patch) | |
tree | bef3c339025b87183a6ad181c2e7898bd1c0e0b8 | |
parent | 26040d64195a9fe39a3e7fc04d06d3180ab2497a (diff) |
avoid using Git.Ref.describe except for when generating user messages
The other uses of it can all be simplified using Git.Ref.base,
Git.Ref.under, and show.
In some cases, describe was being used to shorten the branch name
unnecessarily, and I instead pass the fully qualified name to git.
-rw-r--r-- | Command/Sync.hs | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs index d51994343..38805811a 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -47,13 +47,12 @@ syncRemotes branch [] = defaultSyncRemotes branch syncRemotes _ rs = mapM Remote.byName rs defaultSyncRemotes :: Git.Ref -> Annex [Remote.Remote Annex] -defaultSyncRemotes branch = - mapM Remote.byName +defaultSyncRemotes branch = mapM Remote.byName =<< process . L.unpack <$> inRepo showref - where - syncbranch = Git.Ref $ "refs/heads/synced/" ++ Git.Ref.describe branch + where + syncbranch = Git.Ref.under "refs/heads/synced/" branch showref = Git.Command.pipeRead - [Param "show-ref", Param (Git.Ref.describe syncbranch)] + [Param "show-ref", Param $ show $ Git.Ref.base syncbranch] process = map getRemoteName . filter isRemote . map getBranchName . lines isRemote r = "refs/remotes/" `isPrefixOf` r @@ -71,20 +70,21 @@ commit = do return True mergeLocal :: Git.Ref -> CommandStart -mergeLocal branch = mergeFromIfExists $ Git.Ref $ - "refs/heads/synced/" ++ Git.Ref.describe branch +mergeLocal = mergeFromIfExists . Git.Ref.under "refs/heads/synced" pushLocal :: Git.Ref -> CommandStart pushLocal branch = do - let syncBranch = Git.Ref $ "refs/heads/synced/" ++ Git.Ref.describe branch + let syncBranch = Git.Ref.under "refs/heads/synced" branch ex <- inRepo $ Git.Ref.exists syncBranch if ex then do - showStart "updateing" $ + showStart "updating" $ Git.Ref.describe syncBranch ++ " to the state of " ++ Git.Ref.describe branch ++ "..." next $ next $ inRepo $ Git.Command.runBool "branch" - [Param "-f", Param (Git.Ref.describe syncBranch)] + [ Param "-f" + , Param $ show $ Git.Ref.base syncBranch + ] else return Nothing @@ -109,24 +109,22 @@ fetch remote = do inRepo $ Git.Command.runBool "fetch" [Param (Remote.name remote)] mergeRemote :: Remote.Remote Annex -> Git.Ref -> CommandStart -mergeRemote remote branch = mergeFromIfExists $ Git.Ref $ - "refs/remotes/" ++ Remote.name remote ++ - "/synced/" ++ Git.Ref.describe branch +mergeRemote remote = mergeFromIfExists . + Git.Ref.under ("refs/remotes/" ++ Remote.name remote ++ "/synced") pushRemote :: Remote.Remote Annex -> Git.Ref -> CommandStart pushRemote remote branch = do showStart "pushing to" (Remote.name remote) - let syncbranch = Git.Ref $ "refs/heads/synced/" ++ - Git.Ref.describe branch - let syncbranchRemote = Git.Ref $ "refs/remotes/" ++ - Remote.name remote ++ "/" ++ Git.Ref.describe syncbranch - let refspec = Git.Ref.describe branch ++ ":" ++ Git.Ref.describe syncbranch + let syncbranch = Git.Ref.under "refs/heads/synced" branch + let syncbranchRemote = Git.Ref.under + ("refs/remotes/" ++ Remote.name remote) syncbranch + let refspec = show (Git.Ref.base branch) ++ ":" ++ show (Git.Ref.base syncbranch) ex <- inRepo $ Git.Ref.exists syncbranchRemote next $ next $ do showOutput inRepo $ Git.Command.runBool "push" $ [ Param (Remote.name remote) - , Param (Git.Ref.describe Annex.Branch.name) ] ++ + , Param (show $ Annex.Branch.name) ] ++ [ Param refspec | ex ] currentBranch :: Annex Git.Ref |