@matheusbsbs / matheus-bagliano / commits / 417be08d02
Fork 0

t1300: create custom config file without special characters

Tests that required a custom configuration file to be created previously used a file with non-alphanumeric characters including escaped double quotes. This is not really necessary for the majority of tests involving custom config files, and decreases test coverage on systems that dissallow such filenames (Windows, etc.). Create two files, one appropriate for testing quoting and one appropriate for general use. Signed-off-by: Matthew Rogers <mattr94@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthew Rogers committed Jan 24, 2020 at 00:21 UTC 417be08d02ef5df72996972e105d386028c34653
1 file changed +10 -5
t/t1300-config.sh
+10 -5
@@ -1710,18 +1710,23 @@ test_expect_success '--show-origin getting a single key' '
1710 '
1711
1712 test_expect_success 'set up custom config file' '
1713 - CUSTOM_CONFIG_FILE="file\" (dq) and spaces.conf" &&
1713 + CUSTOM_CONFIG_FILE="custom.conf" &&
1714 cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
1715 [user]
1716 custom = true
1717 EOF
1718 '
1719
1720 +test_expect_success !MINGW 'set up custom config file with special name characters' '
1721 + WEIRDLY_NAMED_FILE="file\" (dq) and spaces.conf" &&
1722 + cp "$CUSTOM_CONFIG_FILE" "$WEIRDLY_NAMED_FILE"
1723 +'
1724 +
1725 test_expect_success !MINGW '--show-origin escape special file name characters' '
1726 cat >expect <<-\EOF &&
1727 file:"file\" (dq) and spaces.conf" user.custom=true
1728 EOF
1724 - git config --file "$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
1729 + git config --file "$WEIRDLY_NAMED_FILE" --show-origin --list >output &&
1730 test_cmp expect output
1731 '
1732
@@ -1747,7 +1752,7 @@ test_expect_success '--show-origin stdin with file include' '
1752 test_cmp expect output
1753 '
1754
1750 -test_expect_success !MINGW '--show-origin blob' '
1755 +test_expect_success '--show-origin blob' '
1756 blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
1757 cat >expect <<-EOF &&
1758 blob:$blob user.custom=true
@@ -1756,9 +1761,9 @@ test_expect_success !MINGW '--show-origin blob' '
1761 test_cmp expect output
1762 '
1763
1759 -test_expect_success !MINGW '--show-origin blob ref' '
1764 +test_expect_success '--show-origin blob ref' '
1765 cat >expect <<-\EOF &&
1761 - blob:"master:file\" (dq) and spaces.conf" user.custom=true
1766 + blob:master:custom.conf user.custom=true
1767 EOF
1768 git add "$CUSTOM_CONFIG_FILE" &&
1769 git commit -m "new config file" &&