config: teach git_config_source to remember its scope

There are many situations where the scope of a config command is known
beforehand, such as passing of '--local', '--file', etc. to an
invocation of git config.  However, this information is lost when moving
from builtin/config.c to /config.c.  This historically hasn't been a big
deal, but to prepare for the upcoming --show-scope option we teach
git_config_source to keep track of the source and the config machinery
to use that information to set current_parsing_scope appropriately.

Signed-off-by: Matthew Rogers <mattr94@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Matthew Rogers
2020-02-10 00:30:57 +00:00
committed by Junio C Hamano
parent 5c105a842e
commit e37efa40e1
3 changed files with 27 additions and 13 deletions

View File

@ -1763,6 +1763,9 @@ int config_with_options(config_fn_t fn, void *data,
data = &inc;
}
if (config_source)
current_parsing_scope = config_source->scope;
/*
* If we have a specific filename, use it. Otherwise, follow the
* regular lookup sequence.