diff --git a/Annex/SpecialRemote.hs b/Annex/SpecialRemote.hs index 759b4701b5..4e55c399b6 100644 --- a/Annex/SpecialRemote.hs +++ b/Annex/SpecialRemote.hs @@ -95,7 +95,7 @@ autoEnable = do Left e -> warning (show e) Right (_c, _u) -> when (cu /= u) $ - setConfig (remoteConfig c "config-uuid") (fromUUID cu) + setConfig (remoteAnnexConfig c "config-uuid") (fromUUID cu) _ -> return () where configured rc = fromMaybe False $ diff --git a/Annex/UUID.hs b/Annex/UUID.hs index f3fc4c8acf..1032acd14e 100644 --- a/Annex/UUID.hs +++ b/Annex/UUID.hs @@ -81,7 +81,7 @@ getRepoUUID r = do updatecache u = do g <- gitRepo when (g /= r) $ storeUUIDIn cachekey u - cachekey = remoteConfig r "uuid" + cachekey = remoteAnnexConfig r "uuid" removeRepoUUID :: Annex () removeRepoUUID = do diff --git a/Assistant/MakeRemote.hs b/Assistant/MakeRemote.hs index cf62cc463e..3b36ef9a51 100644 --- a/Assistant/MakeRemote.hs +++ b/Assistant/MakeRemote.hs @@ -113,7 +113,7 @@ setupSpecialRemote' setdesc name remotetype config mcreds (mu, ss, c) mcu = do Nothing -> configSet u c' Just (Annex.SpecialRemote.ConfigFrom cu) -> do - setConfig (remoteConfig c' "config-uuid") (fromUUID cu) + setConfig (remoteAnnexConfig c' "config-uuid") (fromUUID cu) configSet cu c' when setdesc $ whenM (isNothing . M.lookup u <$> uuidDescMap) $ diff --git a/Assistant/Sync.hs b/Assistant/Sync.hs index a690649369..1bf76c05fc 100644 --- a/Assistant/Sync.hs +++ b/Assistant/Sync.hs @@ -265,7 +265,7 @@ changeSyncable (Just r) False = do changeSyncFlag :: Remote -> Bool -> Annex () changeSyncFlag r enabled = do repo <- Remote.getRepo r - let key = Config.remoteConfig repo "sync" + let key = Config.remoteAnnexConfig repo "sync" Config.setConfig key (boolConfig enabled) void Remote.remoteListRefresh diff --git a/Assistant/WebApp/Configurators/Edit.hs b/Assistant/WebApp/Configurators/Edit.hs index 93a45ef7a9..60661e1811 100644 --- a/Assistant/WebApp/Configurators/Edit.hs +++ b/Assistant/WebApp/Configurators/Edit.hs @@ -306,7 +306,7 @@ getUpgradeRepositoryR r = go =<< liftAnnex (repoIdRemote r) liftAnnex $ do repo <- Remote.getRepo rmt setConfig - (remoteConfig repo "ignore") + (remoteAnnexConfig repo "ignore") (Git.Config.boolConfig False) liftAnnex $ void Remote.remoteListRefresh liftAssistant updateSyncRemotes diff --git a/Command/EnableRemote.hs b/Command/EnableRemote.hs index 1bd9c80b30..976c180fdd 100644 --- a/Command/EnableRemote.hs +++ b/Command/EnableRemote.hs @@ -94,7 +94,7 @@ cleanupSpecialRemote u c mcu = do Nothing -> Logs.Remote.configSet u c Just (SpecialRemote.ConfigFrom cu) -> do - setConfig (remoteConfig c "config-uuid") (fromUUID cu) + setConfig (remoteAnnexConfig c "config-uuid") (fromUUID cu) Logs.Remote.configSet cu c Remote.byUUID u >>= \case Nothing -> noop diff --git a/Command/Export.hs b/Command/Export.hs index aceb2fe545..f66c512d25 100644 --- a/Command/Export.hs +++ b/Command/Export.hs @@ -81,7 +81,7 @@ seek o = do -- handle deprecated option when (exportTracking o) $ - setConfig (remoteConfig r "tracking-branch") + setConfig (remoteAnnexConfig r "tracking-branch") (fromRef $ exportTreeish o) tree <- filterPreferredContent r =<< diff --git a/Command/InitRemote.hs b/Command/InitRemote.hs index d601e39c54..d954c033d7 100644 --- a/Command/InitRemote.hs +++ b/Command/InitRemote.hs @@ -107,7 +107,7 @@ cleanup u name c o = do Logs.Remote.configSet u c Just _ -> do cu <- liftIO genUUID - setConfig (remoteConfig c "config-uuid") (fromUUID cu) + setConfig (remoteAnnexConfig c "config-uuid") (fromUUID cu) Logs.Remote.configSet cu c return True diff --git a/Command/P2P.hs b/Command/P2P.hs index e1896c7a3f..2e3fad53f7 100644 --- a/Command/P2P.hs +++ b/Command/P2P.hs @@ -320,7 +320,7 @@ setupLink remotename (P2PAddressAuth addr authtoken) = do , Param (formatP2PAddress addr) ] when ok $ do - storeUUIDIn (remoteConfig remotename "uuid") theiruuid + storeUUIDIn (remoteAnnexConfig remotename "uuid") theiruuid storeP2PRemoteAuthToken addr authtoken return LinkSuccess go (Right Nothing) = return $ AuthenticationError "Unable to authenticate with peer. Please check the address and try again." diff --git a/Command/Sync.hs b/Command/Sync.hs index d841313395..2e6d4760f4 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -788,7 +788,7 @@ seekExportContent o rs (currbranch, _) = or <$> forM rs go ] _ -> noop where - gitconfig = show (remoteConfig r "tracking-branch") + gitconfig = show (remoteAnnexConfig r "tracking-branch") fillexport _ _ [] _ = return False fillexport r db (tree:[]) mtbcommitsha = do diff --git a/Config.hs b/Config.hs index 971b4207eb..0f5f14d913 100644 --- a/Config.hs +++ b/Config.hs @@ -1,6 +1,6 @@ {- Git configuration - - - Copyright 2011-2019 Joey Hess + - Copyright 2011-2020 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -65,7 +65,11 @@ instance RemoteNameable Remote where {- A per-remote config setting in git config. -} remoteConfig :: RemoteNameable r => r -> UnqualifiedConfigKey -> ConfigKey remoteConfig r key = ConfigKey $ - "remote." <> encodeBS' (getRemoteName r) <> ".annex-" <> key + "remote." <> encodeBS' (getRemoteName r) <> "." <> key + +{- A per-remote config annex setting in git config. -} +remoteAnnexConfig :: RemoteNameable r => r -> UnqualifiedConfigKey -> ConfigKey +remoteAnnexConfig r key = remoteConfig r ("annex-" <> key) {- A global annex setting in git config. -} annexConfig :: UnqualifiedConfigKey -> ConfigKey @@ -81,16 +85,16 @@ remoteCost' :: RemoteGitConfig -> Annex (Maybe Cost) remoteCost' = liftIO . getDynamicConfig . remoteAnnexCost setRemoteCost :: Git.Repo -> Cost -> Annex () -setRemoteCost r c = setConfig (remoteConfig r "cost") (show c) +setRemoteCost r c = setConfig (remoteAnnexConfig r "cost") (show c) setRemoteAvailability :: Git.Repo -> Availability -> Annex () -setRemoteAvailability r c = setConfig (remoteConfig r "availability") (show c) +setRemoteAvailability r c = setConfig (remoteAnnexConfig r "availability") (show c) setRemoteIgnore :: Git.Repo -> Bool -> Annex () -setRemoteIgnore r b = setConfig (remoteConfig r "ignore") (Git.Config.boolConfig b) +setRemoteIgnore r b = setConfig (remoteAnnexConfig r "ignore") (Git.Config.boolConfig b) setRemoteBare :: Git.Repo -> Bool -> Annex () -setRemoteBare r b = setConfig (remoteConfig r "bare") (Git.Config.boolConfig b) +setRemoteBare r b = setConfig (remoteAnnexConfig r "bare") (Git.Config.boolConfig b) isBareRepo :: Annex Bool isBareRepo = fromRepo Git.repoIsLocalBare diff --git a/Remote.hs b/Remote.hs index fb096736ee..7066204c48 100644 --- a/Remote.hs +++ b/Remote.hs @@ -131,7 +131,7 @@ byNameWithUUID = checkuuid <=< byName repo <- getRepo r ifM (liftIO $ getDynamicConfig $ remoteAnnexIgnore (gitconfig r)) ( giveup $ noRemoteUUIDMsg r ++ - " (" ++ show (remoteConfig repo "ignore") ++ + " (" ++ show (remoteAnnexConfig repo "ignore") ++ " is set)" , giveup $ noRemoteUUIDMsg r ) diff --git a/Remote/External.hs b/Remote/External.hs index 750e6ed773..4eedb50bc8 100644 --- a/Remote/External.hs +++ b/Remote/External.hs @@ -169,7 +169,7 @@ externalSetup _ mu _ c gc = do c'' <- case getRemoteConfigValue readonlyField pc of Just True -> do - setConfig (remoteConfig (fromJust (lookupName c)) "readonly") (boolConfig True) + setConfig (remoteAnnexConfig (fromJust (lookupName c)) "readonly") (boolConfig True) return c' _ -> do pc' <- either giveup return $ parseRemoteConfig c' lenientRemoteConfigParser diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs index 3f19070095..780499a8f2 100644 --- a/Remote/GCrypt.hs +++ b/Remote/GCrypt.hs @@ -113,7 +113,7 @@ gen baser u c gc rs = do . parseRemoteConfig c' =<< configParser remote c' setGcryptEncryption pc remotename - storeUUIDIn (remoteConfig baser "uuid") u' + storeUUIDIn (remoteAnnexConfig baser "uuid") u' setConfig (Git.GCrypt.remoteConfigKey "gcrypt-id" remotename) gcryptid gen' r u' pc gc rs _ -> do diff --git a/Remote/Git.hs b/Remote/Git.hs index ca7edc383b..aef6490b38 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -98,10 +98,10 @@ list autoinit = do rs <- mapM (tweakurl c) =<< Annex.getGitRemotes mapM (configRead autoinit) rs where - annexurl n = Git.ConfigKey ("remote." <> encodeBS' n <> ".annexurl") + annexurl r = remoteConfig r "annexurl" tweakurl c r = do let n = fromJust $ Git.remoteName r - case M.lookup (annexurl n) c of + case M.lookup (annexurl r) c of Nothing -> return r Just url -> inRepo $ \g -> Git.Construct.remoteNamed n $ @@ -256,7 +256,7 @@ tryGitConfigRead autoinit r | otherwise -> configlist_failed Left _ -> configlist_failed | Git.repoIsHttp r = storeUpdatedRemote geturlconfig - | Git.GCrypt.isEncrypted r = handlegcrypt =<< getConfigMaybe (remoteConfig r "uuid") + | Git.GCrypt.isEncrypted r = handlegcrypt =<< getConfigMaybe (remoteAnnexConfig r "uuid") | Git.repoIsUrl r = return r | otherwise = storeUpdatedRemote $ liftIO $ readlocalannexconfig `catchNonAsync` (const $ return r) diff --git a/Remote/GitLFS.hs b/Remote/GitLFS.hs index 2f91d1c77a..2005502578 100644 --- a/Remote/GitLFS.hs +++ b/Remote/GitLFS.hs @@ -166,7 +166,7 @@ mySetup _ mu _ c gc = do -- (so it's also usable by git as a non-special remote), -- and set remote.name.annex-git-lfs = true gitConfigSpecialRemote u c' [("git-lfs", "true")] - setConfig (Git.ConfigKey ("remote." <> encodeBS' (getRemoteName c) <> ".url")) url + setConfig (remoteConfig (getRemoteName c) "url") url return (c', u) where url = maybe (giveup "Specify url=") fromProposedAccepted @@ -201,7 +201,7 @@ configKnownUrl r set "config-uuid" (fromUUID cu) r' Nothing -> return r' set k v r' = do - let k' = remoteConfig r' k + let k' = remoteAnnexConfig r' k setConfig k' v return $ Git.Config.store' k' (Git.ConfigValue (encodeBS' v)) r' diff --git a/Remote/Helper/Special.hs b/Remote/Helper/Special.hs index 7c788875a4..a8b945c723 100644 --- a/Remote/Helper/Special.hs +++ b/Remote/Helper/Special.hs @@ -81,8 +81,8 @@ findSpecialRemotes s = do gitConfigSpecialRemote :: UUID -> RemoteConfig -> [(String, String)] -> Annex () gitConfigSpecialRemote u c cfgs = do forM_ cfgs $ \(k, v) -> - setConfig (remoteConfig c (encodeBS' k)) v - storeUUIDIn (remoteConfig c "uuid") u + setConfig (remoteAnnexConfig c (encodeBS' k)) v + storeUUIDIn (remoteAnnexConfig c "uuid") u -- RetrievalVerifiableKeysSecure unless overridden by git config. --