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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 20, 2021, 21:09 UTC
Message-ID
<xmqqczlrugny.fsf@gitster.g>
In-Reply-To
<cc8639fc29db18da00ba2a95a1305efc3ea24205.1640010777.git.gitgitgadget@gmail.com>
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 11 quoted lines
> 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"'.

All good points. Somehow people seem to forget "do not cat a single file into a pipe".

Show 10 quoted lines
> @@ -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 &&
Looks good.  Thanks.
Previous: Phillip Wood via GitGitGadgetNext: Phillip Wood via GitGitGadget
Message 3 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.