public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jialong Wang <jerrywang183@yahoo.com>
Cc: git@vger.kernel.org
Subject: Re: [GSoC PATCH] apply: report input location in binary and garbage patch errors
Date: Tue, 17 Mar 2026 09:08:08 -0700	[thread overview]
Message-ID: <xmqq5x6umobb.fsf@gitster.g> (raw)
In-Reply-To: <20260317002235.6121-1-jerrywang183@yahoo.com> (Jialong Wang's message of "Mon, 16 Mar 2026 20:22:35 -0400")

Jialong Wang <jerrywang183@yahoo.com> writes:

> 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?

> 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

  parent reply	other threads:[~2026-03-17 16:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260317002235.6121-1-jerrywang183.ref@yahoo.com>
2026-03-17  0:22 ` [GSoC PATCH] apply: report input location in binary and garbage patch errors Jialong Wang
2026-03-17  9:40   ` Karthik Nayak
2026-03-17 16:08   ` Junio C Hamano [this message]
2026-03-17 16:21     ` Jialong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq5x6umobb.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jerrywang183@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox