{- To make any git commands be run with ssh caching enabled,
- and configured ssh-options alters the local Git.Repo's gitEnv
- - to set GIT_SSH=git-annex, and sets sshOptionsEnv. -}
+ - to set GIT_SSH=git-annex, and set sshOptionsEnv when running git
+ - commands. -}
sshOptionsTo :: Git.Repo -> RemoteGitConfig -> Git.Repo -> Annex Git.Repo
-sshOptionsTo remote gc g
+sshOptionsTo remote gc localr
| not (Git.repoIsUrl remote) || Git.repoIsHttp remote = unchanged
| otherwise = case Git.Url.hostuser remote of
Nothing -> unchanged
prepSocket sockfile
use (sshConnectionCachingParams sockfile)
where
- unchanged = return g
+ unchanged = return localr
use opts = do
let sshopts = concat
else do
command <- liftIO programPath
liftIO $ do
- g' <- addGitEnv g sshOptionsEnv
+ localr' <- addGitEnv localr sshOptionsEnv
(toSshOptionsEnv sshopts)
- addGitEnv g' "GIT_SSH" command
+ addGitEnv localr' "GIT_SSH" command
runSshOptions :: [String] -> String -> IO ()
runSshOptions args s = do
import qualified Annex.Branch
import Annex.UUID
import Annex.TaggedPush
+import Annex.Ssh
import qualified Config
import Git.Config
import Assistant.NamedThread
go _ _ _ _ [] = return [] -- no remotes, so nothing to do
go shouldretry (Just branch) g u rs = do
debug ["pushing to", show rs]
- (succeeded, failed) <- liftIO $ inParallel (push g branch) rs
+ (succeeded, failed) <- parallelPush g rs (push branch)
updatemap succeeded []
if null failed
then do
fallback branch g u rs = do
debug ["fallback pushing to", show rs]
- (succeeded, failed) <- liftIO $
- inParallel (\r -> taggedPush u Nothing branch r g) rs
+ (succeeded, failed) <- parallelPush g rs (taggedPush u Nothing branch)
updatemap succeeded failed
when (notifypushes && (not $ null succeeded)) $
sendNetMessage $ NotifyPush $
map Remote.uuid succeeded
return failed
- push g branch remote = Command.Sync.pushBranch remote branch g
+ push branch remote = Command.Sync.pushBranch remote branch
+
+parallelPush :: Git.Repo -> [Remote] -> (Remote -> Git.Repo -> IO Bool)-> Assistant ([Remote], [Remote])
+parallelPush g rs a = do
+ rgs <- liftAnnex $ mapM topush rs
+ (succeededrgs, failedrgs) <- liftIO $ inParallel (uncurry a) rgs
+ return (map fst succeededrgs, map fst failedrgs)
+ where
+ topush r = (,)
+ <$> pure r
+ <*> sshOptionsTo (Remote.repo r) (Remote.gitconfig r) g
{- Displays an alert while running an action that syncs with some remotes,
- and returns any remotes that it failed to sync with.
manualPull currentbranch remotes = do
g <- liftAnnex gitRepo
let (xmppremotes, normalremotes) = partition Remote.isXMPPRemote remotes
- failed <- liftIO $ forM normalremotes $ \r ->
- ifM (Git.Command.runBool [Param "fetch", Param $ Remote.name r] g)
+ failed <- forM normalremotes $ \r -> do
+ g' <- liftAnnex $ sshOptionsTo (Remote.repo r) (Remote.gitconfig r) g
+ ifM (liftIO $ Git.Command.runBool [Param "fetch", Param $ Remote.name r] g')
( return Nothing
, return $ Just r
)