aboutsummaryrefslogtreecommitdiff
path: root/Git/Config.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Git/Config.hs')
-rw-r--r--Git/Config.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/Git/Config.hs b/Git/Config.hs
index fb0c24bab..00d1ddba2 100644
--- a/Git/Config.hs
+++ b/Git/Config.hs
@@ -58,11 +58,17 @@ read' repo = go repo
}
{- Gets the global git config, returning a dummy Repo containing it. -}
-global :: IO Repo
+global :: IO (Maybe Repo)
global = do
- repo <- Git.Construct.fromUnknown
- withHandle StdoutHandle createProcessSuccess p $
- hRead repo
+ home <- myHomeDir
+ ifM (doesFileExist $ home </> ".gitconfig")
+ ( do
+ repo <- Git.Construct.fromUnknown
+ repo' <- withHandle StdoutHandle createProcessSuccess p $
+ hRead repo
+ return $ Just repo'
+ , return Nothing
+ )
where
params = ["config", "--null", "--list", "--global"]
p = (proc "git" params)