summaryrefslogtreecommitdiff
path: root/t/t1308-config-set.sh
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2016-05-18 18:44:23 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-05-27 10:45:40 -0700
commit9acc5911119ec0209877fbaa0a1e68aa714c191e (patch)
tree9a5bb0455b12bfd3e6fb3fdf4a6c0aca1af0992c /t/t1308-config-set.sh
parentconfig: return configset value for current_config_ functions (diff)
downloadtgif-9acc5911119ec0209877fbaa0a1e68aa714c191e.tar.xz
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>
Diffstat (limited to 't/t1308-config-set.sh')
-rwxr-xr-xt/t1308-config-set.sh3
1 files changed, 3 insertions, 0 deletions
diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh
index d345a885a3..065d5ebb09 100755
--- a/t/t1308-config-set.sh
+++ b/t/t1308-config-set.sh
@@ -238,16 +238,19 @@ test_expect_success 'iteration shows correct origins' '
value=from-home
origin=file
name=$(pwd)/.gitconfig
+ scope=global
key=foo.bar
value=from-repo
origin=file
name=.git/config
+ scope=repo
key=foo.bar
value=from-cmdline
origin=command line
name=
+ scope=cmdline
EOF
GIT_CONFIG_PARAMETERS=$cmdline_config test-config iterate >actual &&
test_cmp expect actual