diff --git a/Annex.hs b/Annex.hs index 8f60a0bf49..303881fa09 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 874b5c3c9b..505dd06eb2 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 c28ba5afed..bb77b00b31 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 d683e0b98e..ffd2cd46dc 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. -}