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

Re: [PATCH V2] patch-id: fix scan_hunk_header on diffs with 1 line of before/after

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 31, 2022, 23:05 UTC
Message-ID
<xmqqmtjbh5fu.fsf@gitster.g>
In-Reply-To
<20220129024757.24763-1-jerry@skydio.com>
Jerry Zhang <jerry@skydio.com> writes:
Show 10 quoted lines
> diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
> index 80f4a65b28..34a386aee2 100755
> --- a/t/t4204-patch-id.sh
> +++ b/t/t4204-patch-id.sh
> @@ -200,6 +200,36 @@ EOF
>  test_expect_success 'patch-id handles no-nl-at-eof markers' '
>  	cat nonl | calc_patch_id nonl &&
>  	cat withnl | calc_patch_id withnl &&
>  	test_cmp patch-id_nonl patch-id_withnl
>  '

This is not a new issue, but this old test script needs updating. And worse yet, your new test copies the existing badness and make it twice as bad.

We frown upon doing anything outside test_expect_* blocks these days, so the commands to prepare nonl and withnl files before thie precontext of this patch needs to be folded into the test body.

Also, sending a single file using "cat" into pipeline is an antipattern. Just redirect into the downstream command instead, i.e.

	test_expect_success 'patch-id handles no-nl-at-eof markers' '
		cat >nonl <<-\EOF &&
                diff --git i/a w/a
                index e69de29..2e65efe 100644
                --- i/a
                +++ w/a
                @@ -0,0 +1 @@
                +a
                \ No newline at end of file
                diff --git i/b w/b
                index e69de29..6178079 100644
                --- i/b
                +++ w/b
                @@ -0,0 +1 @@
                +b
                EOF
		cat >withnl <<-\EOF &&
		... likewise ...
		EOF
		calc_patch_id nonl <nonl &&
		calc_patch_id withnl <withnl &&
		test_cmp patch-i_ nonl patch-id-withnl
	'
	
or something like that.

I think the "handles no-nl-at-eof markers" test at the end is the first and only serious offender, so instead of leaving it after the series, we probalby would want to have a preliminary clean-up patch before this patch, and fix the test this patch adds.

Thanks.
Previous: Junio C Hamano
Message 6 of 6 in “patch-id: fix scan_hunk_header on diffs with -U1”
  1. patch-id: fix scan_hunk_header on diffs with -U1Jerry Zhang, Jan 25, 2022
  2. Junio C HamanoJan 26, 2022
  3. patch-id: fix scan_hunk_header on diffs with 1 line of before/afterJerry Zhang, Jan 29, 2022
  4. Junio C HamanoJan 31, 2022
  5. Junio C HamanoJan 31, 2022
  6. Junio C HamanoJan 31, 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.