support parsing numeric git configs as bool
I'm not sure if git documents it aside from 0 and 1, but any integer can be interpreted as a bool by it. Doing the same in git-annex is good for consistency. Also, I am planning a config that starts out as a numeric range, but will later transition to a simple bool (hopefully), which this interpretation supports well.
This commit is contained in:
parent
26cf26caca
commit
0121f5f6d3
1 changed files with 4 additions and 0 deletions
|
@ -186,6 +186,10 @@ isTrueFalse' (ConfigValue s)
|
|||
| s' == "0" = Just False
|
||||
| s' == "" = Just False
|
||||
|
||||
-- Git treats any number other than 0 as true,
|
||||
-- including negative numbers.
|
||||
| S8.all (\c -> isDigit c || c == '-') s' = Just True
|
||||
|
||||
| otherwise = Nothing
|
||||
where
|
||||
s' = S8.map toLower s
|
||||
|
|
Loading…
Reference in a new issue