When parsing git configs, support all the documented ways to write true and false, including "yes", "on", "1", etc.
This change does impact git-annex config eg "git annex config --set annex.addunlocked on" will store "on" and new git-annex will understand that value, while old git-annex will error: git-annex: bad annex.addunlocked configuration in git annex config: Parse failure: near "on" That seems acceptable. Not special remote configs that are only documented as =true or =false however. Having git-annex support other values for those would break backwards compatability when used with old versions of git-annex. And older versions ignore invalid special remote configs.. That would not be a good combination.
This commit is contained in:
parent
9cb69dbb76
commit
5a62e8132d
4 changed files with 21 additions and 4 deletions
|
@ -17,7 +17,6 @@ import Types.UUID
|
|||
import Types.ProposedAccepted
|
||||
import Types.RemoteConfig
|
||||
import Types.GitConfig
|
||||
import qualified Git.Config
|
||||
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Set as S
|
||||
|
@ -242,9 +241,17 @@ yesNoParser f v fd = genParser yesno f v fd
|
|||
yesno _ = Nothing
|
||||
|
||||
trueFalseParser :: RemoteConfigField -> Bool -> FieldDesc -> RemoteConfigFieldParser
|
||||
trueFalseParser f v fd = genParser Git.Config.isTrueFalse f v fd
|
||||
trueFalseParser f v fd = genParser trueFalseParser' f v fd
|
||||
(Just (ValueDesc "true or false"))
|
||||
|
||||
-- Not using Git.Config.isTrueFalse because git supports
|
||||
-- a lot of other values for true and false in its configs,
|
||||
-- and this is not a git config and we want to avoid that mess.
|
||||
trueFalseParser' :: String -> Maybe Bool
|
||||
trueFalseParser' "true" = Just True
|
||||
trueFalseParser' "false" = Just False
|
||||
trueFalseParser' _ = Nothing
|
||||
|
||||
genParser
|
||||
:: Typeable t
|
||||
=> (String -> Maybe t)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue