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

[PATCH 1/2] t3701: clean up hunk splitting tests

From
PGPhillip Wood via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 20, 2021, 14:32 UTC
Message-ID
<cc8639fc29db18da00ba2a95a1305efc3ea24205.1640010777.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1100.git.1640010777.gitgitgadget@gmail.com>
From: Phillip Wood <phillip.wood@dunelm.org.uk>
Clean up some test constructs in preparation for extending the tests
in the next commit. There are three small changes, I've grouped them
together as they're so small it didn't seem worth creating three
separate commits.
 1 - "cat file | sed expression" is better written as
     "sed expression file".
 2 - Follow our usual practice of redirecting the output of git
     commands to a file rather than piping it into another command.
 3 - Use test_write_lines rather than 'printf "%s\n"'.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 t/t3701-add-interactive.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 207714655f2..77de0029ba5 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -347,7 +347,7 @@ test_expect_success 'setup patch' '
 # Expected output, diff is similar to the patch but w/ diff at the top
 test_expect_success 'setup expected' '
 	echo diff --git a/file b/file >expected &&
-	cat patch |sed "/^index/s/ 100644/ 100755/" >>expected &&
+	sed "/^index/s/ 100644/ 100755/" patch >>expected &&
 	cat >expected-output <<-\EOF
 	--- a/file
 	+++ b/file
@@ -373,9 +373,9 @@ test_expect_success 'setup expected' '
 test_expect_success 'add first line works' '
 	git commit -am "clear local changes" &&
 	git apply patch &&
-	printf "%s\n" s y y | git add -p file 2>error |
-		sed -n -e "s/^([1-2]\/[1-2]) Stage this hunk[^@]*\(@@ .*\)/\1/" \
-		       -e "/^[-+@ \\\\]"/p  >output &&
+	test_write_lines s y y | git add -p file 2>error >raw-output &&
+	sed -n -e "s/^([1-2]\/[1-2]) Stage this hunk[^@]*\(@@ .*\)/\1/" \
+	       -e "/^[-+@ \\\\]"/p raw-output >output &&
 	test_must_be_empty error &&
 	git diff --cached >diff &&
 	diff_cmp expected diff &&
-- 
gitgitgadget
Previous: Phillip Wood via GitGitGadgetNext: Junio C Hamano
Message 2 of 21 in “builtin add -p: fix hunk splitting”
  1. 0/2 builtin add -p: fix hunk splittingPhillip Wood via GitGitGadget, Dec 20, 2021
  2. 1/2 t3701: clean up hunk splitting testsPhillip Wood via GitGitGadget, Dec 20, 2021
  3. Junio C HamanoDec 20, 2021
  4. 2/2 builtin add -p: fix hunk splittingPhillip Wood via GitGitGadget, Dec 20, 2021
  5. Ævar Arnfjörð BjarmasonDec 20, 2021
  6. Phillip WoodJan 11, 2022
  7. Ævar Arnfjörð BjarmasonJan 11, 2022
  8. Junio C HamanoDec 20, 2021
  9. 0/2 builtin add -p: fix hunk splittingPhillip Wood via GitGitGadget, Jan 11, 2022
  10. 1/2 t3701: clean up hunk splitting testsPhillip Wood via GitGitGadget, Jan 11, 2022
  11. 2/2 builtin add -p: fix hunk splittingPhillip Wood via GitGitGadget, Jan 11, 2022
  12. Ævar Arnfjörð BjarmasonJan 11, 2022
  13. Phillip WoodJan 11, 2022
  14. Junio C HamanoJan 12, 2022
  15. Phillip WoodJan 19, 2022
  16. Junio C HamanoJan 20, 2022
  17. Ævar Arnfjörð BjarmasonJan 20, 2022
  18. Junio C HamanoJan 20, 2022
  19. Johannes SchindelinJan 22, 2022
  20. Phillip WoodJan 24, 2022
  21. Junio C HamanoJan 12, 2022

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.