summaryrefslogtreecommitdiff
path: root/Git/Config.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2015-04-29 14:59:49 -0400
committerJoey Hess <joeyh@joeyh.name>2015-04-29 14:59:49 -0400
commit36852d90bc18cb7b2bddb1ce9dce39cc1f0203de (patch)
tree0419a1d67f6bb9db4ce79f8cb76b53752e2d7371 /Git/Config.hs
parentefe7e174bfab4d0dd2e88e7b6eb859940b2228ea (diff)
downloadgit-repair-36852d90bc18cb7b2bddb1ce9dce39cc1f0203de.tar.gz
Merge from git-annex.
Diffstat (limited to 'Git/Config.hs')
-rw-r--r--Git/Config.hs24
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]