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

Re: Bug in 'git am' when applying a broken patch

From
Greg KH <gregkh@linuxfoundation.org>
Date
Jun 2, 2015, 01:26 UTC
Message-ID
<20150602012614.GD23370@kroah.com>
In-Reply-To
<xmqq8uc35gap.fsf@gitster.dls.corp.google.com>
On Mon, Jun 01, 2015 at 01:23:26PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes:
> 
> > s/enw/new/
> 
> Heh, thanks; I wasn't planning to commit this one yet, but why not.

Well, it's not good to apply a commit with no actual commit. That never a good thing, and was the thing that really confused me about this issue.

Show 36 quoted lines
> Here is with an updated log message and a test.
> 
> -- >8 --
> Subject: [PATCH] apply: reject a hunk that does not do anything
> 
> A hunk like this in a hand-edited patch without correctly adjusting
> the line counts:
> 
>      @@ -660,2 +660,2 @@ inline struct sk_buff *ieee80211_authentic...
>              auth = (struct ieee80211_authentication *)
>                      skb_put(skb, sizeof(struct ieee80211_authentication));
>      -       some old text
>      +       some new text
>      --
>      2.1.0
> 
>      dev mailing list
> 
> at the end of the input does not have a good way for us to diagnose
> it as a corrupt patch.  We just read two context lines and discard
> the remainder as cruft, which we must do in order to ignore the
> e-mail footer.  Notice that the patch does not change anything and
> signal an error.
> 
> Note that this fix will not help if the hand-edited hunk header were
> "@@ -660,3, +660,2" to include the removal.  We would just remove
> the old text without adding the new one, and treat "+ some new text"
> and everything after that line as trailing cruft.  So it is dubious
> that this patch alone would help very much in practice, but it may
> be better than nothing.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  builtin/apply.c        |  3 +++
>  t/t4136-apply-check.sh | 13 +++++++++++++
>  2 files changed, 16 insertions(+)
Looks good to me, thanks for fixing this, much appreciated.
greg k-h
Previous: Junio C HamanoNext: Stefan Beller
Message 8 of 10 in “Bug in 'git am' when applying a broken patch”
  1. Greg KHJun 1, 2015
  2. Greg KHJun 1, 2015
  3. Christian CouderJun 1, 2015
  4. Junio C HamanoJun 1, 2015
  5. Junio C HamanoJun 1, 2015
  6. Eric SunshineJun 1, 2015
  7. Junio C HamanoJun 1, 2015
  8. Greg KHJun 2, 2015
  9. Stefan BellerJun 26, 2015
  10. Junio C HamanoJun 26, 2015

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.