diff options
author | Richard Hartmann <richih@debian.org> | 2015-12-16 07:23:53 +0100 |
---|---|---|
committer | Richard Hartmann <richih@debian.org> | 2015-12-16 07:23:53 +0100 |
commit | 53679fdc47d9470c2540fbe38d5de38c91c3bb01 (patch) | |
tree | e3151adb4d04e905dbb930b67cdb959fac5ea513 /Git/Config.hs | |
parent | c94e89d797b15833875ebeb6adcaa6e130315f8e (diff) | |
parent | 259c511a17669d043a573344e59eae9e9956265c (diff) | |
download | git-repair-53679fdc47d9470c2540fbe38d5de38c91c3bb01.tar.gz |
Merge tag '1.20151215' into debian
tagging package git-repair version 1.20151215
Diffstat (limited to 'Git/Config.hs')
-rw-r--r-- | Git/Config.hs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/Git/Config.hs b/Git/Config.hs index 32c0dd1..3d62395 100644 --- a/Git/Config.hs +++ b/Git/Config.hs @@ -1,6 +1,6 @@ {- git repository configuration handling - - - Copyright 2010-2012 Joey Hess <joey@kitenet.net> + - Copyright 2010-2012 Joey Hess <id@joeyh.name> - - Licensed under the GNU GPL version 3 or higher. -} @@ -14,6 +14,7 @@ import Common import Git import Git.Types import qualified Git.Construct +import qualified Git.Command import Utility.UserInfo {- Returns a single git config setting, or a default value if not set. -} @@ -66,10 +67,9 @@ global = do home <- myHomeDir ifM (doesFileExist $ home </> ".gitconfig") ( do - repo <- Git.Construct.fromUnknown - repo' <- withHandle StdoutHandle createProcessSuccess p $ - hRead repo - return $ Just repo' + repo <- withHandle StdoutHandle createProcessSuccess p $ + hRead (Git.Construct.fromUnknown) + return $ Just repo , return Nothing ) where @@ -194,3 +194,17 @@ changeFile f k v = boolSystem "git" , Param k , Param v ] + +{- Unsets a git config setting, in both the git repo, + - and the cached config in the Repo. + - + - If unsetting the config fails, including in a read-only repo, or + - when the config is not set, returns Nothing. + -} +unset :: String -> Repo -> IO (Maybe Repo) +unset k r = ifM (Git.Command.runBool ps r) + ( return $ Just $ r { config = M.delete k (config r) } + , return Nothing + ) + where + ps = [Param "config", Param "--unset-all", Param k] |