diff options
author | Richard Hartmann <richih@debian.org> | 2015-12-15 23:26:04 -0700 |
---|---|---|
committer | Richard Hartmann <richih@debian.org> | 2015-12-15 23:26:04 -0700 |
commit | d348ed3d2822a8cd4b777f74641baf040e7839e4 (patch) | |
tree | 5d46d93d0b237a213f72e1e7ada60a5fecaf2e75 /Git/Config.hs | |
parent | ad444893f97ed69c4a5f070cb00a6e6cb89bb2cd (diff) | |
parent | 3b6310081cde4333494fb1271a7570fc8e5f333a (diff) | |
download | git-repair-d348ed3d2822a8cd4b777f74641baf040e7839e4.tar.gz |
Record git-repair (1.20151215-1) in archive suite sid
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] |