ssh exit status 255 is a connection problem
Previously, when the git config was unable to be read from a ssh remote, it would try to git fetch from it to determine if the remote was otherwise accessible. That was unnessary work, since exit status 255 indicates a connection problem. As well as avoiding the extra work of the fetch, this also improves things when a ssh remote cannot be connected to due to a problem with the git-annex ssh control socket. In that situation, ssh will also exit 255. Before, the git fetch was tried in that situation, and would succeed, since it does not use the git-annex ssh control socket. git-annex would conclude that git-annex-shell was not installed on the remote, which could be wrong. I suppose it also used to be possible for the user to need to enter a ssh password on each connection to the remote. If they entered the wrong password for the git-annex-shell call, but then the right password for the git fetch, it would also incorrectly set annex-ignore, and that situation is also now fixed.
This commit is contained in:
parent
e8e36a90c1
commit
a19a3076b5
5 changed files with 79 additions and 38 deletions
|
@ -278,14 +278,25 @@ tryGitConfigRead autoinit r hasuuid
|
|||
| Git.repoIsSsh r = storeUpdatedRemote $ do
|
||||
v <- Ssh.onRemote NoConsumeStdin r
|
||||
( pipedconfig Git.Config.ConfigList autoinit (Git.repoDescribe r)
|
||||
, return (Left "configlist failed")
|
||||
, error "internal"
|
||||
)
|
||||
"configlist" [] configlistfields
|
||||
case v of
|
||||
Right r'
|
||||
| haveconfig r' -> return r'
|
||||
| otherwise -> configlist_failed
|
||||
Left _ -> configlist_failed
|
||||
| otherwise -> do
|
||||
configlist_failed
|
||||
return r
|
||||
Left exitcode -> do
|
||||
-- ssh exits 255 when there was an error
|
||||
-- connecting to the remote server.
|
||||
if exitcode /= ExitFailure 255
|
||||
then do
|
||||
configlist_failed
|
||||
return r
|
||||
else do
|
||||
warning $ UnquotedString $ "Unable to connect to repository " ++ Git.repoDescribe r ++ " to get its annex.uuid configuration."
|
||||
return r
|
||||
| Git.repoIsHttp r = storeUpdatedRemote geturlconfig
|
||||
| Git.GCrypt.isEncrypted r = handlegcrypt =<< getConfigMaybe (remoteAnnexConfig r "uuid")
|
||||
| Git.repoIsUrl r = do
|
||||
|
@ -298,31 +309,35 @@ tryGitConfigRead autoinit r hasuuid
|
|||
haveconfig = not . M.null . Git.config
|
||||
|
||||
pipedconfig st mustincludeuuuid configloc cmd params = do
|
||||
v <- liftIO $ Git.Config.fromPipe r cmd params st
|
||||
case v of
|
||||
Right (r', val, _err) -> do
|
||||
(r', val, exitcode, _err) <- liftIO $
|
||||
Git.Config.fromPipe r cmd params st
|
||||
if exitcode == ExitSuccess
|
||||
then do
|
||||
unless (isUUIDConfigured r' || val == mempty || not mustincludeuuuid) $ do
|
||||
warning $ UnquotedString $ "Failed to get annex.uuid configuration of repository " ++ Git.repoDescribe r
|
||||
warning $ UnquotedString $ "Instead, got: " ++ show val
|
||||
warning "This is unexpected; please check the network transport!"
|
||||
return $ Right r'
|
||||
Left l -> do
|
||||
else do
|
||||
warning $ UnquotedString $ "Unable to parse git config from " ++ configloc
|
||||
return $ Left (show l)
|
||||
return $ Left exitcode
|
||||
|
||||
geturlconfig = Url.withUrlOptionsPromptingCreds $ \uo -> do
|
||||
let url = Git.repoLocation r ++ "/config"
|
||||
v <- withTmpFile "git-annex.tmp" $ \tmpfile h -> do
|
||||
liftIO $ hClose h
|
||||
Url.download' nullMeterUpdate Nothing url tmpfile uo >>= \case
|
||||
Right () -> pipedconfig Git.Config.ConfigNullList
|
||||
False url "git"
|
||||
[ Param "config"
|
||||
, Param "--null"
|
||||
, Param "--list"
|
||||
, Param "--file"
|
||||
, File tmpfile
|
||||
]
|
||||
Right () ->
|
||||
pipedconfig Git.Config.ConfigNullList
|
||||
False url "git"
|
||||
[ Param "config"
|
||||
, Param "--null"
|
||||
, Param "--list"
|
||||
, Param "--file"
|
||||
, File tmpfile
|
||||
] >>= return . \case
|
||||
Right r' -> Right r'
|
||||
Left exitcode -> Left $ "git config exited " ++ show exitcode
|
||||
Left err -> return (Left err)
|
||||
case v of
|
||||
Right r' -> do
|
||||
|
@ -342,15 +357,7 @@ tryGitConfigRead autoinit r hasuuid
|
|||
warning $ UnquotedString $ url ++ " " ++ err
|
||||
return r
|
||||
|
||||
{- Is this remote just not available, or does
|
||||
- it not have git-annex-shell?
|
||||
- Find out by trying to fetch from the remote. -}
|
||||
configlist_failed = case Git.remoteName r of
|
||||
Nothing -> return r
|
||||
Just n -> do
|
||||
whenM (inRepo $ Git.Command.runBool [Param "fetch", Param "--quiet", Param n]) $ do
|
||||
set_ignore "does not have git-annex installed" True
|
||||
return r
|
||||
configlist_failed = set_ignore "does not have git-annex installed" True
|
||||
|
||||
set_ignore msg longmessage = do
|
||||
case Git.remoteName r of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue