read_early_config(): really discover .git/
[gitweb.git] / config.c
index b680f79732aa867d39a2e10ac889b5b2abfb1e7f..a88df53fdbca9149e23993319fce6255dc3b6764 100644 (file)
--- a/config.c
+++ b/config.c
@@ -826,7 +826,12 @@ static int git_default_core_config(const char *var, const char *value)
        }
 
        if (!strcmp(var, "core.logallrefupdates")) {
-               log_all_ref_updates = git_config_bool(var, value);
+               if (value && !strcasecmp(value, "always"))
+                       log_all_ref_updates = LOG_REFS_ALWAYS;
+               else if (git_config_bool(var, value))
+                       log_all_ref_updates = LOG_REFS_NORMAL;
+               else
+                       log_all_ref_updates = LOG_REFS_NONE;
                return 0;
        }
 
@@ -1407,6 +1412,31 @@ static void configset_iter(struct config_set *cs, config_fn_t fn, void *data)
        }
 }
 
+void read_early_config(config_fn_t cb, void *data)
+{
+       struct strbuf buf = STRBUF_INIT;
+
+       git_config_with_options(cb, data, NULL, 1);
+
+       /*
+        * When setup_git_directory() was not yet asked to discover the
+        * GIT_DIR, we ask discover_git_directory() to figure out whether there
+        * is any repository config we should use (but unlike
+        * setup_git_directory_gently(), no global state is changed, most
+        * notably, the current working directory is still the same after the
+        * call).
+        */
+       if (!have_git_dir() && discover_git_directory(&buf)) {
+               struct git_config_source repo_config;
+
+               memset(&repo_config, 0, sizeof(repo_config));
+               strbuf_addstr(&buf, "/config");
+               repo_config.file = buf.buf;
+               git_config_with_options(cb, data, &repo_config, 1);
+       }
+       strbuf_release(&buf);
+}
+
 static void git_config_check_init(void);
 
 void git_config(config_fn_t fn, void *data)