]> git.ipfire.org Git - thirdparty/git.git/commit - config.c
config: add a notion of "scope"
authorJeff King <peff@peff.net>
Wed, 18 May 2016 22:44:23 +0000 (18:44 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 May 2016 17:45:40 +0000 (10:45 -0700)
commit9acc5911119ec0209877fbaa0a1e68aa714c191e
tree9a5bb0455b12bfd3e6fb3fdf4a6c0aca1af0992c
parent0d44a2dacc84fb7dcb5d684800e976f3b3c76d00
config: add a notion of "scope"

A config callback passed to git_config() doesn't know very
much about the context in which it sees a variable. It can
ask whether the variable comes from a file, and get the file
name. But without analyzing the filename (which is hard to
do accurately), it cannot tell whether it is in system-level
config, user-level config, or repo-specific config.

Generally this doesn't matter; the point of not passing this
to the callback is that it should treat the config the same
no matter where it comes from. But some programs, like
upload-pack, are a special case: we should be able to run
them in an untrusted repository, which means we cannot use
any "dangerous" config from the repository config file (but
it is OK to use it from system or user config).

This patch teaches the config code to record the "scope" of
each variable, and make it available inside config
callbacks, similar to how we give access to the filename.
The scope is the starting source for a particular parsing
operation, and remains the same even if we include other
files (so a .git/config which includes another file will
remain CONFIG_SCOPE_REPO, as it would be similarly
untrusted).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
config.c
t/helper/test-config.c
t/t1308-config-set.sh