include git-annex-shell back in

Also pushed ConfigKey down into the Git modules, which is the bulk of
the changes.
This commit is contained in:
Joey Hess 2019-12-02 10:57:09 -04:00
parent 65b88a0b99
commit f3047d7186
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
26 changed files with 101 additions and 82 deletions

View file

@ -30,6 +30,7 @@ import Types.GitConfig
import Types.Crypto
import Types.Creds
import Types.Transfer
import Git.Types (ConfigKey(..), fromConfigKey)
import qualified Git
import qualified Git.Command
import qualified Git.Config
@ -99,7 +100,7 @@ gen baser u c gc rs = do
(Just remotename, Just c') -> do
setGcryptEncryption c' remotename
storeUUIDIn (remoteConfig baser "uuid") u'
setConfig (ConfigKey $ Git.GCrypt.remoteConfigKey "gcrypt-id" remotename) gcryptid
setConfig (Git.GCrypt.remoteConfigKey "gcrypt-id" remotename) gcryptid
gen' r u' c' gc rs
_ -> do
warning $ "not using unknown gcrypt repository pointed to by remote " ++ Git.repoDescribe r
@ -256,7 +257,7 @@ setupRepo gcryptid r
| otherwise = localsetup r
where
localsetup r' = do
let setconfig k v = liftIO $ Git.Command.run [Param "config", Param (decodeBS' k), Param v] r'
let setconfig k v = liftIO $ Git.Command.run [Param "config", Param (fromConfigKey k), Param v] r'
setconfig coreGCryptId gcryptid
setconfig denyNonFastForwards (Git.Config.boolConfig False)
return AccessDirect
@ -293,7 +294,7 @@ setupRepo gcryptid r
(\f p -> liftIO (boolSystem f p), return False)
"gcryptsetup" [ Param gcryptid ] []
denyNonFastForwards = "receive.denyNonFastForwards"
denyNonFastForwards = ConfigKey "receive.denyNonFastForwards"
accessShell :: Remote -> Bool
accessShell = accessShellConfig . gitconfig
@ -330,7 +331,7 @@ setGcryptEncryption c remotename = do
Nothing -> noop
Just (KeyIds { keyIds = ks}) -> do
setConfig participants (unwords ks)
let signingkey = ConfigKey $ Git.GCrypt.remoteSigningKey remotename
let signingkey = Git.GCrypt.remoteSigningKey remotename
cmd <- gpgCmd <$> Annex.getGitConfig
skeys <- M.keys <$> liftIO (secretKeys cmd)
case filter (`elem` ks) skeys of
@ -339,7 +340,7 @@ setGcryptEncryption c remotename = do
setConfig (remoteconfig Git.GCrypt.remotePublishParticipantConfigKey)
(Git.Config.boolConfig True)
where
remoteconfig n = ConfigKey $ n remotename
remoteconfig n = n remotename
store :: Remote -> Remote.Rsync.RsyncOpts -> Storer
store r rsyncopts k s p = do
@ -439,7 +440,7 @@ getGCryptUUID fast r = do
(genUUIDInNameSpace gCryptNameSpace <$>) . fst
<$> getGCryptId fast r dummycfg
coreGCryptId :: S.ByteString
coreGCryptId :: ConfigKey
coreGCryptId = "core.gcrypt-id"
{- gcrypt repos set up by git-annex as special remotes have a

View file

@ -88,7 +88,7 @@ list autoinit = do
rs <- mapM (tweakurl c) =<< Annex.getGitRemotes
mapM (configRead autoinit) rs
where
annexurl n = "remote." <> encodeBS' n <> ".annexurl"
annexurl n = Git.ConfigKey ("remote." <> encodeBS' n <> ".annexurl")
tweakurl c r = do
let n = fromJust $ Git.remoteName r
case M.lookup (annexurl n) c of

View file

@ -155,7 +155,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 (ConfigKey ("remote." <> encodeBS' (getRemoteName c) <> ".url")) url
setConfig (Git.ConfigKey ("remote." <> encodeBS' (getRemoteName c) <> ".url")) url
return (c', u)
where
url = fromMaybe (giveup "Specify url=") (M.lookup "url" c)
@ -187,8 +187,8 @@ configKnownUrl r
set "config-uuid" (fromUUID cu) r'
Nothing -> return r'
set k v r' = do
let ck@(ConfigKey k') = remoteConfig r' k
setConfig ck v
let k' = remoteConfig r' k
setConfig k' v
return $ Git.Config.store' k' (encodeBS' v) r'
data LFSHandle = LFSHandle

View file

@ -53,6 +53,7 @@ import Annex.Content
import Messages.Progress
import qualified Git
import qualified Git.Construct
import Git.Types
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
@ -70,7 +71,9 @@ findSpecialRemotes s = do
remotepairs = M.toList . M.filterWithKey match
construct (k,_) = Git.Construct.remoteNamedFromKey k
(pure Git.Construct.fromUnknown)
match k _ = "remote." `S.isPrefixOf` k && (".annex-" <> encodeBS' s) `S.isSuffixOf` k
match (ConfigKey k) _ =
"remote." `S.isPrefixOf` k
&& (".annex-" <> encodeBS' s) `S.isSuffixOf` k
{- Sets up configuration for a special remote in .git/config. -}
gitConfigSpecialRemote :: UUID -> RemoteConfig -> [(String, String)] -> Annex ()