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

Re: [GSoC PATCH] apply: report input location in binary and garbage patch errors

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 17, 2026, 16:08 UTC
Message-ID
<xmqq5x6umobb.fsf@gitster.g>
In-Reply-To
<20260317002235.6121-1-jerrywang183@yahoo.com>
Jialong Wang <jerrywang183@yahoo.com> writes:
Show 21 quoted lines
> diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh
> index b3d93d8ed6..8393076469 100755
> --- a/t/t4100-apply-stat.sh
> +++ b/t/t4100-apply-stat.sh
> @@ -125,4 +125,16 @@ test_expect_success 'applying a patch with an invalid mode reports the input' '
>  	EOF
>  	test_cmp expect err
>  '
> +
> +test_expect_success 'applying a patch with only garbage reports the input' '
> +	cat >garbage.patch <<-\EOF &&
> +	diff --git a/f b/f
> +	--- a/f
> +	+++ b/f
> +	this is garbage
> +	EOF
> +	test_must_fail git apply garbage.patch 2>err &&
> +	echo "error: patch with only garbage at garbage.patch:4" >expect &&
> +	test_cmp expect err
> +'
>  test_done

What is this patch based on? Can we have a consolidated either a single patch or a series of patches that form a single topic?

Show 30 quoted lines
> diff --git a/t/t4103-apply-binary.sh b/t/t4103-apply-binary.sh
> index 8e302a5a57..f2d41e06bc 100755
> --- a/t/t4103-apply-binary.sh
> +++ b/t/t4103-apply-binary.sh
> @@ -179,6 +179,24 @@ test_expect_success PERL_TEST_HELPERS 'reject truncated binary diff' '
>  	" <patch >patch.trunc &&
>  
>  	do_reset &&
> -	test_must_fail git apply patch.trunc
> +	test_must_fail git apply patch.trunc 2>err &&
> +	line=$(awk "END { print NR + 1 }" patch.trunc) &&
> +	grep "error: corrupt binary patch at patch.trunc:$line: " err
> +'
> +
> +test_expect_success 'reject unrecognized binary diff' '
> +	cat >patch.bad <<-\EOF &&
> +	diff --git a/f b/f
> +	new file mode 100644
> +	index 0000000..7898192
> +	GIT binary patch
> +	bogus
> +	EOF
> +	test_must_fail git apply patch.bad 2>err &&
> +	cat >expect <<-\EOF &&
> +	error: unrecognized binary patch at patch.bad:4
> +	error: No valid patches in input (allow with "--allow-empty")
> +	EOF
> +	test_cmp expect err
>  '
>  test_done
Previous: Karthik NayakNext: Jialong Wang
Message 3 of 4 in “apply: report input location in binary and garbage patch errors”
  1. apply: report input location in binary and garbage patch errorsJialong Wang, Mar 17, 2026
  2. Karthik NayakMar 17, 2026
  3. Junio C HamanoMar 17, 2026
  4. Jialong WangMar 17, 2026

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.