From 99984967eb878113dd34d70a73b8dd9bb12ef182 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 7 Apr 2017 13:51:06 -0400 Subject: [PATCH] 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. --- CHANGELOG | 3 +++ Command/EnableRemote.hs | 33 +++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fc0e6512dd..3d9ed22a21 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 Wed, 29 Mar 2017 12:41:46 -0400 diff --git a/Command/EnableRemote.hs b/Command/EnableRemote.hs index 3addd87d7e..b9b53a69c1 100644 --- a/Command/EnableRemote.hs +++ b/Command/EnableRemote.hs @@ -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