Read configuration also from ~/.gitconfig
[git.git] / config.c
index c474970..bbd3ff2 100644 (file)
--- a/config.c
+++ b/config.c
@@ -317,7 +317,18 @@ int git_config_from_file(config_fn_t fn, const char *filename)
 
 int git_config(config_fn_t fn)
 {
-       return git_config_from_file(fn, git_path("config"));
+       int ret = 0;
+       const char *home = getenv("HOME");
+
+       if (home) {
+               ret = git_config_from_file(fn, mkpath("%s/.gitconfig", home));
+               /* ignore if global config does not exist */
+               if (ret < 0)
+                       ret = 0;
+       }
+
+       ret += git_config_from_file(fn, git_path("config"));
+       return ret;
 }
 
 /*