better error message when git config fails to parse remote config
Rather than leaking the name of the temp file, just say the config parse failed, and where the config was downloaded from. Not closing the bug report because two issues were reported in the same bug report, because the universe wants me to continually re-read old unclosed bug reports to waste my time determining what still needs to be done.
This commit is contained in:
parent
6cc1f1dce9
commit
75059c9f3b
5 changed files with 30 additions and 14 deletions
|
@ -56,6 +56,7 @@ import Utility.Tmp
|
|||
import Logs.Remote
|
||||
import Utility.Gpg
|
||||
import Utility.SshHost
|
||||
import Utility.Tuple
|
||||
import Messages.Progress
|
||||
import Types.ProposedAccepted
|
||||
|
||||
|
@ -471,7 +472,7 @@ getGCryptId :: Bool -> Git.Repo -> RemoteGitConfig -> Annex (Maybe Git.GCrypt.GC
|
|||
getGCryptId fast r gc
|
||||
| Git.repoIsLocal r || Git.repoIsLocalUnknown r = extract <$>
|
||||
liftIO (catchMaybeIO $ Git.Config.read r)
|
||||
| not fast = extract . liftM fst <$> getM (eitherToMaybe <$>)
|
||||
| not fast = extract . liftM fst3 <$> getM (eitherToMaybe <$>)
|
||||
[ Ssh.onRemote NoConsumeStdin r (\f p -> liftIO (Git.Config.fromPipe r f p), return (Left $ error "configlist failed")) "configlist" [] []
|
||||
, getConfigViaRsync r gc
|
||||
]
|
||||
|
@ -480,7 +481,7 @@ getGCryptId fast r gc
|
|||
extract Nothing = (Nothing, r)
|
||||
extract (Just r') = (fromConfigValue <$> Git.Config.getMaybe coreGCryptId r', r')
|
||||
|
||||
getConfigViaRsync :: Git.Repo -> RemoteGitConfig -> Annex (Either SomeException (Git.Repo, S.ByteString))
|
||||
getConfigViaRsync :: Git.Repo -> RemoteGitConfig -> Annex (Either SomeException (Git.Repo, S.ByteString, S.ByteString))
|
||||
getConfigViaRsync r gc = do
|
||||
(rsynctransport, rsyncurl, _) <- rsyncTransport r gc
|
||||
opts <- rsynctransport
|
||||
|
|
|
@ -248,7 +248,7 @@ tryGitConfigRead autoinit r
|
|||
| haveconfig r = return r -- already read
|
||||
| Git.repoIsSsh r = storeUpdatedRemote $ do
|
||||
v <- Ssh.onRemote NoConsumeStdin r
|
||||
(pipedconfig autoinit, return (Left $ giveup "configlist failed"))
|
||||
(pipedconfig autoinit (Git.repoDescribe r), return (Left $ giveup "configlist failed"))
|
||||
"configlist" [] configlistfields
|
||||
case v of
|
||||
Right r'
|
||||
|
@ -263,23 +263,25 @@ tryGitConfigRead autoinit r
|
|||
where
|
||||
haveconfig = not . M.null . Git.config
|
||||
|
||||
pipedconfig mustincludeuuuid cmd params = do
|
||||
pipedconfig mustincludeuuuid configloc cmd params = do
|
||||
v <- liftIO $ Git.Config.fromPipe r cmd params
|
||||
case v of
|
||||
Right (r', val) -> do
|
||||
Right (r', val, _err) -> do
|
||||
unless (isUUIDConfigured r' || S.null val || not mustincludeuuuid) $ do
|
||||
warning $ "Failed to get annex.uuid configuration of repository " ++ Git.repoDescribe r
|
||||
warning $ "Instead, got: " ++ show val
|
||||
warning $ "This is unexpected; please check the network transport!"
|
||||
return $ Right r'
|
||||
Left l -> return $ Left l
|
||||
Left l -> do
|
||||
warning $ "Unable to parse git config from " ++ configloc
|
||||
return $ Left l
|
||||
|
||||
geturlconfig = Url.withUrlOptions $ \uo -> do
|
||||
v <- withTmpFile "git-annex.tmp" $ \tmpfile h -> do
|
||||
liftIO $ hClose h
|
||||
let url = Git.repoLocation r ++ "/config"
|
||||
ifM (liftIO $ Url.downloadQuiet nullMeterUpdate url tmpfile uo)
|
||||
( Just <$> pipedconfig False "git" [Param "config", Param "--null", Param "--list", Param "--file", File tmpfile]
|
||||
( Just <$> pipedconfig False url "git" [Param "config", Param "--null", Param "--list", Param "--file", File tmpfile]
|
||||
, return Nothing
|
||||
)
|
||||
case v of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue