support boolean git configs that are represented by the name of the setting with no value
Eg"core.bare" is the same as "core.bare = true". Note that git treats "core.bare =" the same as "core.bare = false", so the code had to become more complicated in order to treat the absense of a value differently than an empty value. Ugh.
This commit is contained in:
parent
ca9c6c5f60
commit
9cb69dbb76
8 changed files with 35 additions and 7 deletions
|
@ -135,6 +135,7 @@ updateLocation' r l = do
|
|||
top <- absPath $ fromRawFilePath (gitdir l)
|
||||
let p = absPathFrom top (fromRawFilePath d)
|
||||
return $ l { worktree = Just (toRawFilePath p) }
|
||||
Just NoConfigValue -> return l
|
||||
return $ r { location = l' }
|
||||
|
||||
data ConfigStyle = ConfigList | ConfigNullList
|
||||
|
@ -152,8 +153,12 @@ parse s st
|
|||
eq = fromIntegral (ord '=')
|
||||
|
||||
sep c = M.fromListWith (++)
|
||||
. map (\(k,v) -> (ConfigKey k, [ConfigValue (S.drop 1 v)]))
|
||||
. map (\(k,v) -> (ConfigKey k, [mkval v]))
|
||||
. map (S.break (== c))
|
||||
|
||||
mkval v
|
||||
| S.null v = NoConfigValue
|
||||
| otherwise = ConfigValue (S.drop 1 v)
|
||||
|
||||
{- Checks if a string from git config is a true/false value. -}
|
||||
isTrueFalse :: String -> Maybe Bool
|
||||
|
@ -166,6 +171,7 @@ isTrueFalse' (ConfigValue s)
|
|||
| otherwise = Nothing
|
||||
where
|
||||
s' = S8.map toLower s
|
||||
isTrueFalse' NoConfigValue = Just True
|
||||
|
||||
boolConfig :: Bool -> String
|
||||
boolConfig True = "true"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue