[RFC/PATCH 2/2] config: Add test of safe-include feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds a script for testing various aspects of the safe-include feature.

Signed-off-by: Rasmus Villemoes <rv@xxxxxxxxxxxxxxxxxx>
---
 t/t1309-config-safe-include.sh | 96 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100755 t/t1309-config-safe-include.sh

diff --git a/t/t1309-config-safe-include.sh b/t/t1309-config-safe-include.sh
new file mode 100755
index 0000000..b8ccc94
--- /dev/null
+++ b/t/t1309-config-safe-include.sh
@@ -0,0 +1,96 @@
+#!/bin/sh
+
+test_description='test config file safe-include directives'
+. ./test-lib.sh
+
+
+test_expect_success 'blacklist by default' '
+	echo "[diff]external = badprog" >project &&
+	echo "[safe-include]path = project" >.gitconfig &&
+	test_must_fail git config diff.external
+'
+
+
+test_expect_success 'builtin safe rules' '
+	echo "[diff]renames = true" >project &&
+	echo "[safe-include]path = project" >.gitconfig &&
+	echo true >expect &&
+	git config diff.renames >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'user blacklist taking precedence' '
+	echo "[diff]renames = true" >project &&
+	cat >.gitconfig <<-\EOF &&
+	[diff]renames = false
+	[safe-include]whitelist = !diff.renames
+	[safe-include]path = project
+	EOF
+	echo false >expect &&
+	git config diff.renames >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'wildcard matching' '
+	cat >project <<-\EOF &&
+	[test]beer = true
+	[test]bar = true
+	[test]foo = true
+	EOF
+	cat >.gitconfig <<-\EOF &&
+	[safe-include]whitelist = test.b*r
+	[safe-include]path = project
+	EOF
+	printf "test.bar true\ntest.beer true\n" | sort >expect &&
+	git config --get-regexp "^test" | sort >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'ignore whitelist directives in safe-included files' '
+	cat >project <<-\EOF &&
+	[safe-include]whitelist = *
+	[diff]external = badprog
+	EOF
+	echo "[safe-include]path = project" >.gitconfig &&
+	test_must_fail git config diff.external
+'
+
+test_expect_success 'multiple whitelist/blacklist patterns in one line' '
+	cat >.gitconfig <<-\EOF &&
+	[safe-include]whitelist = !* foo.bar squirrel.* !squirrel.xyz
+	[safe-include]path = project
+	EOF
+	cat >project <<-\EOF &&
+	[diff]renames = true
+	[foo]bar = bar
+	[squirrel]abc = abc
+	[squirrel]xyz = xyz
+	EOF
+	test_must_fail git config diff.renames &&
+	test_must_fail git config squirrel.xyz &&
+	echo bar >expect &&
+	git config foo.bar >actual &&
+	test_cmp expect actual
+	echo abc >expect &&
+	git config squirrel.abc >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'case insensitivity' '
+	cat >.gitconfig <<-\EOF &&
+	[safe-include]whitelist = Test.Abc test.xyz
+	[safe-include]path = project
+	EOF
+	cat >project <<-\EOF &&
+	[test]abc = abc
+	[TeST]XyZ = XyZ
+	EOF
+	echo abc >expect &&
+	git config test.abc >actual &&
+	test_cmp expect actual &&
+	echo XyZ >expect &&
+	git config test.xyz >actual &&
+	test_cmp expect actual
+'
+
+test_done
-- 
2.0.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]