Read configuration also from ~/.gitconfig
[git.git] / config.c
index 2ae6153..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;
 }
 
 /*
@@ -536,7 +547,7 @@ int git_config_set_multivar(const char* key, const char* value,
         * contents of .git/config will be written into it.
         */
        fd = open(lock_file, O_WRONLY | O_CREAT | O_EXCL, 0666);
-       if (fd < 0) {
+       if (fd < 0 || adjust_shared_perm(lock_file)) {
                fprintf(stderr, "could not lock config file\n");
                free(store.key);
                ret = -1;