summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-01 00:04:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-01 00:04:53 -0400
commit99c522edeff6add3ece41922f862c59b5afdddbe (patch)
treecbeb49c44117e9a8c41740508a276f92a216dd73
parent0bd7ebbf356c2753fbd6e29b925efef0b4eb3f74 (diff)
finished adding support for annex.ssh-options
-rw-r--r--Annex.hs2
-rw-r--r--GitRepo.hs17
-rw-r--r--Remotes.hs7
-rw-r--r--UUID.hs2
4 files changed, 17 insertions, 11 deletions
diff --git a/Annex.hs b/Annex.hs
index 8f60a0bf4..303881fa0 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -45,7 +45,7 @@ new gitrepo allbackends = do
where
prep = do
-- read git config and update state
- gitrepo' <- liftIO $ Git.configRead gitrepo
+ gitrepo' <- liftIO $ Git.configRead gitrepo Nothing
Annex.gitRepoChange gitrepo'
{- performs an action in the Annex monad -}
diff --git a/GitRepo.hs b/GitRepo.hs
index 874b5c3c9..505dd06eb 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -246,9 +246,11 @@ pipeNullSplit repo params = do
where
split0 s = filter (not . null) $ split "\0" s
-{- Runs git config and populates a repo with its config. -}
-configRead :: Repo -> IO Repo
-configRead repo@(Repo { location = Dir d }) = do
+{- Runs git config and populates a repo with its config.
+ -
+ - For a ssh repository, a list of ssh options may optionally be specified. -}
+configRead :: Repo -> Maybe [String] -> IO Repo
+configRead repo@(Repo { location = Dir d }) _ = do
{- Cannot use pipeRead because it relies on the config having
been already read. Instead, chdir to the repo. -}
cwd <- getCurrentDirectory
@@ -256,10 +258,13 @@ configRead repo@(Repo { location = Dir d }) = do
(\_ -> changeWorkingDirectory cwd) $
pOpen ReadFromPipe "git" ["config", "--list"] $
hConfigRead repo
-configRead repo = assertSsh repo $ do
- pOpen ReadFromPipe "ssh" [urlHost repo, sshcommand] $ hConfigRead repo
+configRead repo sshopts = assertSsh repo $ do
+ pOpen ReadFromPipe "ssh" params $ hConfigRead repo
where
- sshcommand = "cd " ++ (shellEscape $ urlPath repo) ++
+ params = case sshopts of
+ Nothing -> [urlHost repo, command]
+ Just l -> l ++ [urlHost repo, command]
+ command = "cd " ++ (shellEscape $ urlPath repo) ++
" && git config --list"
hConfigRead :: Repo -> Handle -> IO Repo
hConfigRead repo h = do
diff --git a/Remotes.hs b/Remotes.hs
index c28ba5afe..bb77b00b3 100644
--- a/Remotes.hs
+++ b/Remotes.hs
@@ -94,8 +94,8 @@ inAnnex r key = do
Annex.eval a (Core.inAnnex key)
checkremote = do
Core.showNote ("checking " ++ Git.repoDescribe r ++ "...")
- inannex <- runCmd r ("test -e " ++
- (shellEscape $ annexLocation r key)) []
+ inannex <- runCmd r "test"
+ [ "-e", (shellEscape $ annexLocation r key)]
-- XXX Note that ssh failing and the file not existing
-- are not currently differentiated.
return $ Right inannex
@@ -172,11 +172,12 @@ commandLineRemote = do
- returns the updated git repo. -}
tryGitConfigRead :: Git.Repo -> Annex (Either Git.Repo Git.Repo)
tryGitConfigRead r = do
+ sshoptions <- repoConfig r "annex-ssh-options" ""
if (Map.null $ Git.configMap r)
then do
-- configRead can fail due to IO error or
-- for other reasons; catch all possible exceptions
- result <- liftIO $ (try (Git.configRead r)::IO (Either SomeException (Git.Repo)))
+ result <- liftIO $ (try (Git.configRead r $ Just $ words sshoptions)::IO (Either SomeException (Git.Repo)))
case (result) of
Left _ -> return $ Left r
Right r' -> do
diff --git a/UUID.hs b/UUID.hs
index d683e0b98..ffd2cd46d 100644
--- a/UUID.hs
+++ b/UUID.hs
@@ -83,7 +83,7 @@ setConfig key value = do
g <- Annex.gitRepo
liftIO $ Git.run g ["config", key, value]
-- re-read git config and update the repo's state
- g' <- liftIO $ Git.configRead g
+ g' <- liftIO $ Git.configRead g Nothing
Annex.gitRepoChange g'
{- Filters a list of repos to ones that have listed UUIDs. -}