git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 1/3] t: fix quotes tests for --pathspec-from-file

From
AGAlexandr Miloslavskiy via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 31, 2019, 10:15 UTC
Message-ID
<ce0c592bb436112727d3636ce9a77494cd0ba8e3.1577787313.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.503.v4.git.1577787313.gitgitgadget@gmail.com>
From: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>

While working on the next patch, I also noticed that quotes testing via `"\"file\\101.t\""` was somewhat incorrect: I escaped `\` one time while I had to escape it two times! Tests still worked due to `"` being preserved which in turn prevented pathspec from matching files.

Fix this by using here-doc instead.
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
---
 t/t2026-checkout-pathspec-file.sh | 11 +++++++++--
 t/t2072-restore-pathspec-file.sh  | 11 +++++++++--
 t/t3704-add-pathspec-file.sh      | 11 +++++++++--
 t/t7107-reset-pathspec-file.sh    | 12 +++++++++---
 t/t7526-commit-pathspec-file.sh   | 11 +++++++++--
 5 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/t/t2026-checkout-pathspec-file.sh b/t/t2026-checkout-pathspec-file.sh
index f62fd27440..adad71f631 100755
--- a/t/t2026-checkout-pathspec-file.sh
+++ b/t/t2026-checkout-pathspec-file.sh
@@ -109,7 +109,11 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
 	restore_checkpoint &&
 
-	printf "\"file\\101.t\"" | git checkout --pathspec-from-file=- HEAD^1 &&
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
+	git checkout --pathspec-from-file=list HEAD^1 &&
 
 	cat >expect <<-\EOF &&
 	M  fileA.t
@@ -120,7 +124,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
 	restore_checkpoint &&
 
-	printf "\"file\\101.t\"" >list &&
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
 	test_must_fail git checkout --pathspec-from-file=list --pathspec-file-nul HEAD^1
 '
 
diff --git a/t/t2072-restore-pathspec-file.sh b/t/t2072-restore-pathspec-file.sh
index db58e83735..b407f6b779 100755
--- a/t/t2072-restore-pathspec-file.sh
+++ b/t/t2072-restore-pathspec-file.sh
@@ -109,7 +109,11 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
 	restore_checkpoint &&
 
-	printf "\"file\\101.t\"" | git restore --pathspec-from-file=- --source=HEAD^1 &&
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
+	git restore --pathspec-from-file=list --source=HEAD^1 &&
 
 	cat >expect <<-\EOF &&
 	 M fileA.t
@@ -120,7 +124,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
 	restore_checkpoint &&
 
-	printf "\"file\\101.t\"" >list &&
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
 	test_must_fail git restore --pathspec-from-file=list --pathspec-file-nul --source=HEAD^1
 '
 
diff --git a/t/t3704-add-pathspec-file.sh b/t/t3704-add-pathspec-file.sh
index 3cfdb669b7..61b6e51009 100755
--- a/t/t3704-add-pathspec-file.sh
+++ b/t/t3704-add-pathspec-file.sh
@@ -97,7 +97,11 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
 	restore_checkpoint &&
 
-	printf "\"file\\101.t\"" | git add --pathspec-from-file=- &&
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
+	git add --pathspec-from-file=list &&
 
 	cat >expect <<-\EOF &&
 	A  fileA.t
@@ -108,7 +112,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
 	restore_checkpoint &&
 
-	printf "\"file\\101.t\"" >list &&
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
 	test_must_fail git add --pathspec-from-file=list --pathspec-file-nul
 '
 
diff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh
index 6b1a731fff..b0e84cdb42 100755
--- a/t/t7107-reset-pathspec-file.sh
+++ b/t/t7107-reset-pathspec-file.sh
@@ -105,8 +105,12 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
 	restore_checkpoint &&
 
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
 	git rm fileA.t &&
-	printf "\"file\\101.t\"" | git reset --pathspec-from-file=- &&
+	git reset --pathspec-from-file=list &&
 
 	cat >expect <<-\EOF &&
 	 D fileA.t
@@ -117,8 +121,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
 	restore_checkpoint &&
 
-	git rm fileA.t &&
-	printf "\"file\\101.t\"" >list &&
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
 	# Note: "git reset" has not yet learned to fail on wrong pathspecs
 	git reset --pathspec-from-file=list --pathspec-file-nul &&
 
diff --git a/t/t7526-commit-pathspec-file.sh b/t/t7526-commit-pathspec-file.sh
index 4b58901ed6..4a7c11368d 100755
--- a/t/t7526-commit-pathspec-file.sh
+++ b/t/t7526-commit-pathspec-file.sh
@@ -100,7 +100,11 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
 	restore_checkpoint &&
 
-	printf "\"file\\101.t\"" | git commit --pathspec-from-file=- -m "Commit" &&
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
+	git commit --pathspec-from-file=list -m "Commit" &&
 
 	cat >expect <<-\EOF &&
 	A	fileA.t
@@ -111,7 +115,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
 	restore_checkpoint &&
 
-	printf "\"file\\101.t\"" >list &&
+	cat >list <<-\EOF &&
+	"file\101.t"
+	EOF
+
 	test_must_fail git commit --pathspec-from-file=list --pathspec-file-nul -m "Commit"
 '
 
-- 
gitgitgadget
Previous: Alexandr Miloslavskiy via GitGitGadgetNext: Alexandr Miloslavskiy via GitGitGadget
Message 19 of 26 in “t: rework tests for --pathspec-from-file”
  1. 0/3 t: rework tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 30, 2019
  2. 1/3 t: fix quotes tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 30, 2019
  3. 2/3 t: directly test parse_pathspec_file()Alexandr Miloslavskiy via GitGitGadget, Dec 30, 2019
  4. Junio C HamanoDec 30, 2019
  5. Alexandr MiloslavskiyDec 30, 2019
  6. 3/3 t: drop copy&pasted tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 30, 2019
  7. 0/3 t: rework tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 30, 2019
  8. 2/3 t: directly test parse_pathspec_file()Alexandr Miloslavskiy via GitGitGadget, Dec 30, 2019
  9. 1/3 t: fix quotes tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 30, 2019
  10. Eric SunshineDec 30, 2019
  11. Jonathan NiederDec 31, 2019
  12. Alexandr MiloslavskiyDec 31, 2019
  13. 3/3 t: drop copy&pasted tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 30, 2019
  14. 0/3 t: rework tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 31, 2019
  15. 2/3 t: directly test parse_pathspec_file()Alexandr Miloslavskiy via GitGitGadget, Dec 31, 2019
  16. 1/3 t: fix quotes tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 31, 2019
  17. 3/3 t: drop copy&pasted tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 31, 2019
  18. 0/3 t: rework tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 31, 2019
  19. 1/3 t: fix quotes tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 31, 2019
  20. 2/3 t: directly test parse_pathspec_file()Alexandr Miloslavskiy via GitGitGadget, Dec 31, 2019
  21. 3/3 t: drop copy&pasted tests for --pathspec-from-fileAlexandr Miloslavskiy via GitGitGadget, Dec 31, 2019
  22. Junio C HamanoJan 7, 2020
  23. Alexandr MiloslavskiyJan 8, 2020
  24. Junio C HamanoJan 8, 2020
  25. Alexandr MiloslavskiyJan 8, 2020
  26. Junio C HamanoJan 8, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.