summaryrefslogtreecommitdiff
path: root/t/t1350-config-hooks-path.sh
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2016-05-18 18:41:08 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-05-24 13:21:59 -0700
commit3258258f51f45efeff5ce0e9f825f347a1404efa (patch)
tree3b8a2d7e7dcf286d98fa903f13565ca7510fc17f /t/t1350-config-hooks-path.sh
parentgit_config_parse_parameter: refactor cleanup code (diff)
downloadtgif-3258258f51f45efeff5ce0e9f825f347a1404efa.tar.xz
config: set up config_source for command-line config
When we parse a config file, we set up the global "cf" variable as a pointer to a "struct config_source" describing the file we are parsing. This is used for error messages, as well as for lookup functions like current_config_name(). The "cf" variable is NULL in two cases: 1. When we are parsing command-line config, in which case there is no source file. 2. When we are not parsing any config at all. Callers like current_config_name() must assume we are in case 1 if they see a NULL "cf". However, this means that if they are accidentally used outside of a config parsing callback, they will quietly return a bogus answer. This might seem like an unlikely accident (why would you ask for the current config file if you are not parsing config?), but it's actually an easy mistake to make due to the configset caching. git_config() serves the answers from a configset cache, and any calls to current_config_name() will claim that we are parsing command-line config, no matter what the original source. So let's distinguish these cases by having the command-line config parser set up a config_source with a NULL name (which callers already handle properly). We can use this to catch programming errors in some cases, and to give better messages to the user in others. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1350-config-hooks-path.sh')
0 files changed, 0 insertions, 0 deletions