improve error message when SETCREDS overwrites git-annex config
That is not allowed, so it's not a bug in git-annex when it happens and instead tell the special remote developer how it's messed up. Note that currently only Remote.External can overwrite the parsed remote config with a PassedThrough value. PassedThrough values are otherwise only generated for configs that are not parsed by the remote config parser. Sponsored-by: Joshua Antonishen
This commit is contained in:
parent
378541cc78
commit
cbb4a2bf86
2 changed files with 41 additions and 7 deletions
|
@ -206,13 +206,23 @@ getRemoteConfigValue :: HasCallStack => Typeable v => RemoteConfigField -> Parse
|
|||
getRemoteConfigValue f (ParsedRemoteConfig m _) = case M.lookup f m of
|
||||
Just (RemoteConfigValue v) -> case cast v of
|
||||
Just v' -> Just v'
|
||||
Nothing -> error $ unwords
|
||||
[ "getRemoteConfigValue"
|
||||
, fromProposedAccepted f
|
||||
, "found value of unexpected type"
|
||||
, show (typeOf v) ++ "."
|
||||
, "This is a bug in git-annex!"
|
||||
]
|
||||
Nothing -> case cast v :: Maybe PassedThrough of
|
||||
-- Handle the case where an external special remote
|
||||
-- tries to SETCONFIG a value belonging to git-annex,
|
||||
-- resulting in a PassedThrough type being stored.
|
||||
Just _ -> error $ unwords
|
||||
[ "Special remote config "
|
||||
, fromProposedAccepted f
|
||||
, "has been overwritten by SETCONFIG."
|
||||
, "This is not supported."
|
||||
]
|
||||
Nothing -> error $ unwords
|
||||
[ "getRemoteConfigValue"
|
||||
, fromProposedAccepted f
|
||||
, "found value of unexpected type"
|
||||
, show (typeOf v) ++ "."
|
||||
, "This is a bug in git-annex!"
|
||||
]
|
||||
Nothing -> Nothing
|
||||
|
||||
{- Gets all fields that remoteConfigRestPassthrough matched. -}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 8"""
|
||||
date="2025-09-16T16:57:11Z"
|
||||
content="""
|
||||
SETCONFIG is limited to setting the external program's configuration,
|
||||
not to reaching inside git-annex and setting its own configuration.
|
||||
The docs say that, but could perhaps be more clear.
|
||||
|
||||
I have improved the error message.
|
||||
|
||||
git-annex sets up encryption for the remote based on the encryption= and
|
||||
encryptonlycreds= settings before it ever starts up the external program.
|
||||
That would need to change in order to support this.
|
||||
|
||||
But I'm also doubtful it would be a good idea to support SETCONFIG
|
||||
of any of the things git-annex uses for encryption, chunking, etc.
|
||||
It's essentially monkey-patching git-annex from the external program.
|
||||
Some changes to git-annex's configs could lead to very unexpected behavior.
|
||||
|
||||
If you really need the ability to turn on onlyencryptcreds by default
|
||||
with your special remote, there will need to be some other way implemented
|
||||
to do it. Please open a new todo about that.
|
||||
"""]]
|
Loading…
Add table
Add a link
Reference in a new issue