Skip to content

Commit 21627f9

Browse files
peffgitster
authored andcommitted
check_repository_format_gently: stop using git_config_early
There's a chicken-and-egg problem with using the regular git_config during the repository setup process. We get around it here by using a special interface that lets us specify the per-repo config, and avoid calling git_pathdup(). But this interface doesn't actually make sense. It will look in the system and per-user config, too; we definitely would not want to accept a core.repositoryformatversion from there. The git_config_from_file interface is a better match, as it lets us look at a single file. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae5f677 commit 21627f9

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

setup.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,10 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
409409
repo_config = sb.buf;
410410

411411
/*
412-
* git_config() can't be used here because it calls git_pathdup()
413-
* to get $GIT_CONFIG/config. That call will make setup_git_env()
414-
* set git_dir to ".git".
415-
*
416-
* We are in gitdir setup, no git dir has been found useable yet.
417-
* Use a gentler version of git_config() to check if this repo
418-
* is a good one.
412+
* Ignore return value; for historical reasons, we must treat a missing
413+
* config file as a noop (git-init relies on this).
419414
*/
420-
git_config_early(fn, NULL, repo_config);
415+
git_config_from_file(fn, repo_config, NULL);
421416
if (GIT_REPO_VERSION_READ < repository_format_version) {
422417
if (!nongit_ok)
423418
die ("Expected git repo version <= %d, found %d",

0 commit comments

Comments
 (0)