path: root/t/
diff options
authorJeff King <>2014-02-18 22:58:52 (GMT)
committerJunio C Hamano <>2014-02-19 00:12:09 (GMT)
commitd14d42440d8370f8fe5016a6e212d101745f70cc (patch)
tree74c9093cc6de89aa208252782f437bd798cde149 /t/
parent5f95c9f850b19b368c43ae399cc831b17a26a5ac (diff)
config: disallow relative include paths from blobs
When we see a relative config include like: [include] path = foo we make it relative to the containing directory of the file that contains the snippet. This makes no sense for config read from a blob, as it is not on the filesystem. Something like "HEAD:some/path" could have a relative path within the tree, but: 1. It would not be part of include.path, which explicitly refers to the filesystem. 2. It would need different parsing rules anyway to determine that it is a tree path. The current code just uses the "name" field, which is wrong. Let's split that into "name" and "path" fields, use the latter for relative includes, and fill in only the former for blobs. Signed-off-by: Jeff King <> Signed-off-by: Kirill A. Shutemov <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 16 insertions, 0 deletions
diff --git a/t/ b/t/
index a707076..6edd38b 100755
--- a/t/
+++ b/t/
@@ -122,6 +122,22 @@ test_expect_success 'relative includes from command line fail' '
test_must_fail git -c include.path=one config
+test_expect_success 'absolute includes from blobs work' '
+ echo "[test]one = 1" >one &&
+ echo "[include]path=$(pwd)/one" >blob &&
+ blob=$(git hash-object -w blob) &&
+ echo 1 >expect &&
+ git config --blob=$blob >actual &&
+ test_cmp expect actual
+test_expect_success 'relative includes from blobs fail' '
+ echo "[test]one = 1" >one &&
+ echo "[include]path=one" >blob &&
+ blob=$(git hash-object -w blob) &&
+ test_must_fail git config --blob=$blob
test_expect_success 'include cycles are detected' '
cat >.gitconfig <<-\EOF &&
[test]value = gitconfig