summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-17 20:50:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-17 20:50:28 (GMT)
commita0393a298fecff8cdc17aba51245f29433520d81 (patch)
treea6491d24988a63b067193fc852902ae41933b00d /config.c
parent81944e9b54039f8475d1df5c40e5a1055eae14f6 (diff)
parent5c4003ca3f0e9ac6d3c8aa3e387ff843bd440411 (diff)
downloadgit-a0393a298fecff8cdc17aba51245f29433520d81.zip
git-a0393a298fecff8cdc17aba51245f29433520d81.tar.gz
git-a0393a298fecff8cdc17aba51245f29433520d81.tar.bz2
Merge branch 'js/early-config'
The start-up sequence of "git" needs to figure out some configured settings before it finds and set itself up in the location of the repository and was quite messy due to its "chicken-and-egg" nature. The code has been restructured. * js/early-config: setup.c: mention unresolved problems t1309: document cases where we would want early config not to die() setup_git_directory_gently_1(): avoid die()ing t1309: test read_early_config() read_early_config(): really discover .git/ read_early_config(): avoid .git/config hack when unneeded setup: make read_early_config() reusable setup: introduce the discover_git_directory() function setup_git_directory_1(): avoid changing global state setup: prepare setup_discovered_git_dir() for the root directory setup_git_directory(): use is_dir_sep() helper t7006: replace dubious test
Diffstat (limited to 'config.c')
-rw-r--r--config.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/config.c b/config.c
index bd286b3..eb7e310 100644
--- a/config.c
+++ b/config.c
@@ -1503,6 +1503,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)