Skip to content

Commit 267b453

Browse files
dschogitster
authored andcommitted
read_early_config(): avoid .git/config hack when unneeded
So far, we only look whether the startup_info claims to have seen a git_dir. However, do_git_config_sequence() (and consequently the git_config_with_options() call used by read_early_config() asks the have_git_dir() function whether we have a .git/ directory, which in turn also looks at git_dir and at the environment variable GIT_DIR. And when this is the case, the repository config is handled already, so we do not have to do that again explicitly. Let's just use the same function, have_git_dir(), to determine whether we have to handle .git/config explicitly. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0654aa5 commit 267b453

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

config.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,14 +1427,15 @@ void read_early_config(config_fn_t cb, void *data)
14271427
* core.repositoryformatversion), we'll read whatever is in .git/config
14281428
* blindly. Similarly, if we _are_ in a repository, but not at the
14291429
* root, we'll fail to find .git/config (because it's really
1430-
* ../.git/config, etc). See t7006 for a complete set of failures.
1430+
* ../.git/config, etc), unless setup_git_directory() was already called.
1431+
* See t7006 for a complete set of failures.
14311432
*
14321433
* However, we have historically provided this hack because it does
14331434
* work some of the time (namely when you are at the top-level of a
14341435
* valid repository), and would rarely make things worse (i.e., you do
14351436
* not generally have a .git/config file sitting around).
14361437
*/
1437-
if (!startup_info->have_repository) {
1438+
if (!have_git_dir()) {
14381439
struct git_config_source repo_config;
14391440

14401441
memset(&repo_config, 0, sizeof(repo_config));

0 commit comments

Comments
 (0)