avoid beware of the leopard situation
* Display a warning message when a remote uses a protocol, such as git://, that git-annex does not support. Silently skipping such a remote was confusing behavior. It sets annex-ignore, so the warning is only displayed once. * Also display a warning message when a remote, without a known uuid, is located in a directory that does not currently exist, to avoid silently skipping such a remote. This is a bit more debatable, since git-annex get will say, try making repository available. And since it does not set annex-ignore, the warning will be displayed repeatedly. It's also an extreme edge case, I don't think I've ever seen it happen in real life.
This commit is contained in:
parent
5d407aa5a4
commit
f9ed30de3b
4 changed files with 61 additions and 11 deletions
|
@ -149,15 +149,15 @@ gitSetup (Enable _) Nothing _ _ _ = error "unable to enable git remote with no s
|
|||
configRead :: Bool -> Git.Repo -> Annex Git.Repo
|
||||
configRead autoinit r = do
|
||||
gc <- Annex.getRemoteGitConfig r
|
||||
u <- getRepoUUID r
|
||||
hasuuid <- (/= NoUUID) <$> getRepoUUID r
|
||||
annexignore <- liftIO $ getDynamicConfig (remoteAnnexIgnore gc)
|
||||
case (repoCheap r, annexignore, u) of
|
||||
case (repoCheap r, annexignore, hasuuid) of
|
||||
(_, True, _) -> return r
|
||||
(True, _, _)
|
||||
| remoteAnnexCheckUUID gc -> tryGitConfigRead autoinit r
|
||||
| remoteAnnexCheckUUID gc -> tryGitConfigRead autoinit r hasuuid
|
||||
| otherwise -> return r
|
||||
(False, _, NoUUID) -> configSpecialGitRemotes r >>= \case
|
||||
Nothing -> tryGitConfigRead autoinit r
|
||||
(False, _, False) -> configSpecialGitRemotes r >>= \case
|
||||
Nothing -> tryGitConfigRead autoinit r False
|
||||
Just r' -> return r'
|
||||
_ -> return r
|
||||
|
||||
|
@ -244,8 +244,8 @@ repoAvail r
|
|||
|
||||
{- Tries to read the config for a specified remote, updates state, and
|
||||
- returns the updated repo. -}
|
||||
tryGitConfigRead :: Bool -> Git.Repo -> Annex Git.Repo
|
||||
tryGitConfigRead autoinit r
|
||||
tryGitConfigRead :: Bool -> Git.Repo -> Bool -> Annex Git.Repo
|
||||
tryGitConfigRead autoinit r hasuuid
|
||||
| haveconfig r = return r -- already read
|
||||
| Git.repoIsSsh r = storeUpdatedRemote $ do
|
||||
v <- Ssh.onRemote NoConsumeStdin r
|
||||
|
@ -258,9 +258,12 @@ tryGitConfigRead autoinit r
|
|||
Left _ -> configlist_failed
|
||||
| Git.repoIsHttp r = storeUpdatedRemote geturlconfig
|
||||
| Git.GCrypt.isEncrypted r = handlegcrypt =<< getConfigMaybe (remoteAnnexConfig r "uuid")
|
||||
| Git.repoIsUrl r = return r
|
||||
| otherwise = storeUpdatedRemote $ liftIO $
|
||||
readlocalannexconfig `catchNonAsync` (const $ return r)
|
||||
| Git.repoIsUrl r = do
|
||||
set_ignore "uses a protocol not supported by git-annex" False
|
||||
return r
|
||||
| otherwise = storeUpdatedRemote $
|
||||
liftIO readlocalannexconfig
|
||||
`catchNonAsync` const failedreadlocalconfig
|
||||
where
|
||||
haveconfig = not . M.null . Git.config
|
||||
|
||||
|
@ -339,6 +342,13 @@ tryGitConfigRead autoinit r
|
|||
s <- Annex.new r
|
||||
Annex.eval s $ check `finally` stopCoProcesses
|
||||
|
||||
failedreadlocalconfig = do
|
||||
unless hasuuid $ case Git.remoteName r of
|
||||
Nothing -> noop
|
||||
Just n -> do
|
||||
warning $ "Remote " ++ n ++ " cannot currently be accessed."
|
||||
return r
|
||||
|
||||
configlistfields = if autoinit
|
||||
then [(Fields.autoInit, "1")]
|
||||
else []
|
||||
|
@ -898,7 +908,7 @@ mkState r u gc = do
|
|||
rv <- liftIO newEmptyMVar
|
||||
let getrepo = ifM (liftIO $ isEmptyMVar rv)
|
||||
( do
|
||||
r' <- tryGitConfigRead False r
|
||||
r' <- tryGitConfigRead False r True
|
||||
let t = (r', extractGitConfig FromGitConfig r')
|
||||
void $ liftIO $ tryPutMVar rv t
|
||||
return t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue