summaryrefslogtreecommitdiff
path: root/builtin/init-db.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-09-12 20:24:23 -0700
committerJunio C Hamano <gitster@pobox.com>2016-09-13 15:45:45 -0700
commit4543926ba8f8ec596dd4e45f206f4fbc29350567 (patch)
treed79c4bb1d4514f2a184e2b3213db6301868c68ae /builtin/init-db.c
parent7c0a842b46391230661d17ad758efa6b4eccdb93 (diff)
downloadgit-4543926ba8f8ec596dd4e45f206f4fbc29350567.tar.gz
init: reset cached config when entering new repo
After we copy the templates into place, we re-read the config in case we copied in a default config file. But since git_config() is backed by a cache these days, it's possible that the call will not actually touch the filesystem at all; we need to tell it that something has changed behind the scenes. Note that we also need to reset the shared_repository config. At first glance, it seems like this should probably just be folded into git_config_clear(). But unfortunately that is not quite right. The shared repository value may come from config, _or_ it may have been set manually. So only the caller who knows whether or not they set it is the one who can clear it (and indeed, if you _do_ put it into git_config_clear(), then many tests fail, as we have to clear the config cache any time we set a new config variable). There are three tests here. The first two actually pass already, though it's largely luck: they just don't happen to actually read any config before we enter the new repo. But the third one does fail without this patch; we look at core.sharedrepository while creating the directory, but need to make sure the value from the template config overrides it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/init-db.c')
-rw-r--r--builtin/init-db.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 0b0557138d..cc09fca81b 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -195,8 +195,14 @@ static int create_default_files(const char *template_path)
* First copy the templates -- we might have the default
* config file there, in which case we would want to read
* from it after installing.
+ *
+ * Before reading that config, we also need to clear out any cached
+ * values (since we've just potentially changed what's available on
+ * disk).
*/
copy_templates(template_path);
+ git_config_clear();
+ reset_shared_repository();
git_config(git_default_config, NULL);
/*