Skip to content

Commit 5c105a8

Browse files
ROGERSM94gitster
authored andcommitted
config: preserve scope in do_git_config_sequence
do_git_config_sequence operated under the assumption that it was correct to set current_parsing_scope to CONFIG_SCOPE_UNKNOWN as part of the cleanup it does after it finishes execution. This is incorrect, as it blows away the current_parsing_scope if do_git_config_sequence is called recursively. As such situations are rare (git config running with the '--blob' option is one example) this has yet to cause a problem, but the upcoming '--show-scope' option will experience issues in that case, lets teach do_git_config_sequence to preserve the current_parsing_scope from before it started execution. Signed-off-by: Matthew Rogers <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6766e41 commit 5c105a8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,7 @@ static int do_git_config_sequence(const struct config_options *opts,
17021702
char *xdg_config = xdg_config_home("config");
17031703
char *user_config = expand_user_path("~/.gitconfig", 0);
17041704
char *repo_config;
1705+
enum config_scope prev_parsing_scope = current_parsing_scope;
17051706

17061707
if (opts->commondir)
17071708
repo_config = mkpathdup("%s/config", opts->commondir);
@@ -1741,7 +1742,7 @@ static int do_git_config_sequence(const struct config_options *opts,
17411742
if (!opts->ignore_cmdline && git_config_from_parameters(fn, data) < 0)
17421743
die(_("unable to parse command-line config"));
17431744

1744-
current_parsing_scope = CONFIG_SCOPE_UNKNOWN;
1745+
current_parsing_scope = prev_parsing_scope;
17451746
free(xdg_config);
17461747
free(user_config);
17471748
free(repo_config);

0 commit comments

Comments
 (0)