summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-05-16 16:08:20 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-05-16 16:08:20 -0400
commitf4b3a2aee0052962f3f82c03f137c62f17d64e18 (patch)
tree00ec330f89eebb9ded13689a82e7c2ab1d31c36a /Remote
parentce4a677871eb33b5989005f6af209d6384d5f8a8 (diff)
factor out getRemoteGitConfig
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Bup.hs5
-rw-r--r--Remote/Git.hs5
-rw-r--r--Remote/Helper/Ssh.hs15
-rw-r--r--Remote/List.hs4
4 files changed, 12 insertions, 17 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index afb1e78dd..778832850 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -13,7 +13,7 @@ import System.Process
import Data.ByteString.Lazy.UTF8 (fromString)
import Common.Annex
-import Types.GitConfig
+import qualified Annex
import Types.Remote
import Types.Key
import Types.Creds
@@ -224,8 +224,7 @@ storeBupUUID u buprepo = do
onBupRemote :: Git.Repo -> (FilePath -> [CommandParam] -> IO a) -> FilePath -> [CommandParam] -> Annex a
onBupRemote r a command params = do
- g <- fromRepo id
- let c = extractRemoteGitConfig g (Git.repoDescribe r)
+ c <- Annex.getRemoteGitConfig r
sshparams <- Ssh.toRepo r c [Param $
"cd " ++ dir ++ " && " ++ unwords (command : toCommand params)]
liftIO $ a "ssh" sshparams
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 2a6ed0c77..5b9a72a01 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -87,10 +87,9 @@ list = do
- cached UUID value. -}
configRead :: Git.Repo -> Annex Git.Repo
configRead r = do
- g <- fromRepo id
- let c = extractRemoteGitConfig g (Git.repoDescribe r)
+ gc <- Annex.getRemoteGitConfig r
u <- getRepoUUID r
- case (repoCheap r, remoteAnnexIgnore c, u) of
+ case (repoCheap r, remoteAnnexIgnore gc, u) of
(_, True, _) -> return r
(True, _, _) -> tryGitConfigRead r
(False, _, NoUUID) -> tryGitConfigRead r
diff --git a/Remote/Helper/Ssh.hs b/Remote/Helper/Ssh.hs
index 745e9c025..05a98865f 100644
--- a/Remote/Helper/Ssh.hs
+++ b/Remote/Helper/Ssh.hs
@@ -8,13 +8,13 @@
module Remote.Helper.Ssh where
import Common.Annex
+import qualified Annex
import qualified Git
import qualified Git.Url
import Annex.UUID
import Annex.Ssh
import CmdLine.GitAnnexShell.Fields (Field, fieldName)
import qualified CmdLine.GitAnnexShell.Fields as Fields
-import Types.GitConfig
import Types.Key
import Remote.Helper.Messages
import Utility.Metered
@@ -27,8 +27,8 @@ import Config
- Caller is responsible for doing any neccessary shellEscaping of the
- passed command. -}
toRepo :: Git.Repo -> RemoteGitConfig -> [CommandParam] -> Annex [CommandParam]
-toRepo r c sshcmd = do
- let opts = map Param $ remoteAnnexSshOptions c
+toRepo r gc sshcmd = do
+ let opts = map Param $ remoteAnnexSshOptions gc
let host = fromMaybe (error "bad ssh url") $ Git.Url.hostuser r
params <- sshCachingOptions (host, Git.Url.port r) opts
return $ params ++ Param host : sshcmd
@@ -39,18 +39,17 @@ git_annex_shell :: Git.Repo -> String -> [CommandParam] -> [(Field, String)] ->
git_annex_shell r command params fields
| not $ Git.repoIsUrl r = return $ Just (shellcmd, shellopts ++ fieldopts)
| Git.repoIsSsh r = do
- g <- fromRepo id
- let c = extractRemoteGitConfig g (Git.repoDescribe r)
+ gc <- Annex.getRemoteGitConfig r
u <- getRepoUUID r
- sshparams <- toRepo r c [Param $ sshcmd u c]
+ sshparams <- toRepo r gc [Param $ sshcmd u gc]
return $ Just ("ssh", sshparams)
| otherwise = return Nothing
where
dir = Git.repoPath r
shellcmd = "git-annex-shell"
shellopts = Param command : File dir : params
- sshcmd u c = unwords $
- fromMaybe shellcmd (remoteAnnexShell c)
+ sshcmd u gc = unwords $
+ fromMaybe shellcmd (remoteAnnexShell gc)
: map shellEscape (toCommand shellopts) ++
uuidcheck u ++
map shellEscape (toCommand fieldopts)
diff --git a/Remote/List.hs b/Remote/List.hs
index 221ab9a54..1ec2c32b4 100644
--- a/Remote/List.hs
+++ b/Remote/List.hs
@@ -15,7 +15,6 @@ import Common.Annex
import qualified Annex
import Logs.Remote
import Types.Remote
-import Types.GitConfig
import Annex.UUID
import Remote.Helper.Hooks
import Remote.Helper.ReadOnly
@@ -94,8 +93,7 @@ remoteListRefresh = do
remoteGen :: M.Map UUID RemoteConfig -> RemoteType -> Git.Repo -> Annex (Maybe Remote)
remoteGen m t r = do
u <- getRepoUUID r
- g <- fromRepo id
- let gc = extractRemoteGitConfig g (Git.repoDescribe r)
+ gc <- Annex.getRemoteGitConfig r
let c = fromMaybe M.empty $ M.lookup u m
mrmt <- generate t r u c gc
return $ adjustReadOnly . addHooks <$> mrmt