Read configuration also from ~/.gitconfig
[git.git] / config.c
index 0248c6d..bbd3ff2 100644 (file)
--- a/config.c
+++ b/config.c
@@ -269,6 +269,11 @@ int git_default_config(const char *var, const char *value)
                return 0;
        }
 
+       if (!strcmp(var, "core.logallrefupdates")) {
+               log_all_ref_updates = git_config_bool(var, value);
+               return 0;
+       }
+
        if (!strcmp(var, "core.warnambiguousrefs")) {
                warn_ambiguous_refs = git_config_bool(var, value);
                return 0;
@@ -312,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;
 }
 
 /*
@@ -531,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;