enableremote: Fix re-enabling of existing gcrypt remotes, so that eg, encryption key changes take effect.

They were silently ignored, a reversion introduced in 6.20160527.

I don't like this regular git remote special case in enableremote, but I
can't see a way to get rid of it. So, check if the existing remote is
a Remote.Git

This commit was sponsored by Trenton Cronholm on Patreon.
This commit is contained in:
Joey Hess 2017-04-07 13:51:06 -04:00
parent f406d16525
commit 99984967eb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 24 additions and 12 deletions

View file

@ -14,6 +14,9 @@ git-annex (6.20170322) UNRELEASED; urgency=medium
the parameters that git passes.
* enableremote: When enabling a non-special remote, param=value
parameters can't be used, so error out if any are provided.
* enableremote: Fix re-enabling of existing gcrypt remotes, so
that eg, encryption key changes take effect. They were silently
ignored, a reversion introduced in 6.20160527.
-- Joey Hess <id@joeyh.name> Wed, 29 Mar 2017 12:41:46 -0400

View file

@ -39,19 +39,28 @@ start (name:rest) = go =<< filter matchingname <$> Annex.fromRepo Git.remotes
matchingname r = Git.remoteName r == Just name
go [] = startSpecialRemote name (Logs.Remote.keyValToConfig rest)
=<< Annex.SpecialRemote.findExisting name
go (r:_)
| null rest = startNormalRemote name r
| otherwise = giveup $
"That is a normal git remote; passing these parameters does not make sense: " ++ unwords rest
go (r:_) = do
-- This could be either a normal git remote or a special
-- remote that has an url (eg gcrypt).
rs <- Remote.remoteList
case filter (\rmt -> Remote.name rmt == name) rs of
(rmt:_) | Remote.remotetype rmt == Remote.Git.remote ->
startNormalRemote name rest r
_ -> go []
startNormalRemote :: Git.RemoteName -> Git.Repo -> CommandStart
startNormalRemote name r = do
showStart "enableremote" name
next $ next $ do
setRemoteIgnore r False
r' <- Remote.Git.configRead False r
u <- getRepoUUID r'
return $ u /= NoUUID
-- Normal git remotes are special-cased; enableremote retries probing
-- the remote uuid.
startNormalRemote :: Git.RemoteName -> [String] -> Git.Repo -> CommandStart
startNormalRemote name restparams r
| null restparams = do
showStart "enableremote" name
next $ next $ do
setRemoteIgnore r False
r' <- Remote.Git.configRead False r
u <- getRepoUUID r'
return $ u /= NoUUID
| otherwise = giveup $
"That is a normal git remote; passing these parameters does not make sense: " ++ unwords restparams
startSpecialRemote :: Git.RemoteName -> Remote.RemoteConfig -> Maybe (UUID, Remote.RemoteConfig) -> CommandStart
startSpecialRemote name config Nothing = do