[PATCH 3/4] t1300: add more tests for whitespace and inline comments
From: Dragan Simic <hidden>
Date: 2024-03-15 13:22:18
Subsystem:
the rest · Maintainer:
Linus Torvalds
Add a handful of additional automated tests, to improve the coverage of configuration file entries whose values contain internal whitespace, leading and/or trailing whitespace, or which contain an additional inline comment. Signed-off-by: Dragan Simic <redacted> --- t/t1300-config.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-)
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 31c387868708..6eef8a48098c 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh@@ -11,6 +11,96 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh +cat > .git/config << EOF +[section] + solid = rock + sparse = big blue + sparseAndTail = big blue + sparseAndTailQuoted = "big blue " + sparseAndBiggerTail = big blue + sparseAndBiggerTailQuoted = "big blue " + sparseAndBiggerTailQuotedPlus = "big blue " + headAndTail = big blue + headAndTailQuoted = " big blue " + headAndTailQuotedPlus = " big blue " + annotated = big blue # to be discarded + annotatedQuoted = "big blue" # to be discarded +EOF + +echo 'rock' > expect + +test_expect_success 'no internal whitespace' ' + git config --get section.solid > output && + test_cmp expect output +' + +echo 'big blue' > expect + +test_expect_success 'internal whitespace' ' + git config --get section.sparse > output && + test_cmp expect output +' + +test_expect_success 'internal and trailing whitespace' ' + git config --get section.sparseAndTail > output && + test_cmp expect output +' + +test_expect_success 'internal and more trailing whitespace' ' + git config --get section.sparseAndBiggerTail > output && + test_cmp expect output +' + +echo 'big blue ' > expect + +test_expect_success 'internal and trailing whitespace, all quoted' ' + git config --get section.sparseAndTailQuoted > output && + test_cmp expect output +' + +echo 'big blue ' > expect + +test_expect_success 'internal and more trailing whitespace, all quoted' ' + git config --get section.sparseAndBiggerTailQuoted > output && + test_cmp expect output +' + +test_expect_success 'internal and more trailing whitespace, not all quoted' ' + git config --get section.sparseAndBiggerTailQuotedPlus > output && + test_cmp expect output +' + +echo 'big blue' > expect + +test_expect_success 'leading and trailing whitespace' ' + git config --get section.headAndTail > output && + test_cmp expect output +' + +echo ' big blue ' > expect + +test_expect_success 'leading and trailing whitespace, all quoted' ' + git config --get section.headAndTailQuoted > output && + test_cmp expect output +' + +test_expect_success 'leading and trailing whitespace, not all quoted' ' + git config --get section.headAndTailQuotedPlus > output && + test_cmp expect output +' + +echo 'big blue' > expect + +test_expect_success 'inline comment' ' + git config --get section.annotated > output && + test_cmp expect output +' + +test_expect_success 'inline comment, quoted' ' + git config --get section.annotatedQuoted > output && + test_cmp expect output +' + test_expect_success 'clear default config' ' rm -f .git/config '
@@ -1066,7 +1156,17 @@ test_expect_success '--null --get-regexp' ' test_cmp expect result ' -test_expect_success 'inner whitespace kept verbatim' ' +test_expect_success 'inner whitespace kept verbatim, spaces only' ' + git config section.val "foo bar" && + test_cmp_config "foo bar" section.val +' + +test_expect_success 'inner whitespace kept verbatim, horizontal tabs only' ' + git config section.val "foo bar" && + test_cmp_config "foo bar" section.val +' + +test_expect_success 'inner whitespace kept verbatim, horizontal tabs and spaces' ' git config section.val "foo bar" && test_cmp_config "foo bar" section.val '