diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2012-09-23 12:43:14 -0400 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2012-09-23 12:43:14 -0400 |
commit | 582316f66f0e664d65c78e408807c535b4ef66e2 (patch) | |
tree | fdff2000d17c5588651174ceec682568ef658f64 | |
parent | 377636850e154e74836016520c0b346251409242 (diff) |
avoid webapp crash on startup when there's no ~/.gitconfig
git config --list --global exits nonzero when there's no global config
-rw-r--r-- | Command/WebApp.hs | 2 | ||||
-rw-r--r-- | Git/Config.hs | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/Command/WebApp.hs b/Command/WebApp.hs index ae37b324c..f44053250 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -105,7 +105,7 @@ firstRun = do putMVar v "" takeMVar v mainthread v _url htmlshim = do - browser <- webBrowser <$> Git.Config.global + browser <- maybe Nothing webBrowser <$> Git.Config.global openBrowser browser htmlshim _wait <- takeMVar v 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) |