diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-03-17 13:50:28 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-17 13:50:28 -0700 |
commit | a0393a298fecff8cdc17aba51245f29433520d81 (patch) | |
tree | a6491d24988a63b067193fc852902ae41933b00d /config.c | |
parent | 81944e9b54039f8475d1df5c40e5a1055eae14f6 (diff) | |
parent | 5c4003ca3f0e9ac6d3c8aa3e387ff843bd440411 (diff) | |
download | git-a0393a298fecff8cdc17aba51245f29433520d81.tar.gz |
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.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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) |