git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Eric Sunshine <sunshine@sunshineco.com>,
	Git List <git@vger.kernel.org>,
	Gaston Gonzalez <gascoar@gmail.com>
Subject: Re: Bug in 'git am' when applying a broken patch
Date: Tue, 2 Jun 2015 10:26:14 +0900	[thread overview]
Message-ID: <20150602012614.GD23370@kroah.com> (raw)
In-Reply-To: <xmqq8uc35gap.fsf@gitster.dls.corp.google.com>

On Mon, Jun 01, 2015 at 01:23:26PM -0700, Junio C Hamano wrote:
> 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.

> 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

  reply	other threads:[~2015-06-02  1:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01  0:17 Bug in 'git am' when applying a broken patch Greg KH
2015-06-01  1:54 ` Greg KH
2015-06-01 12:09   ` Christian Couder
2015-06-01 18:31 ` Junio C Hamano
2015-06-01 18:58   ` Junio C Hamano
2015-06-01 20:09     ` Eric Sunshine
2015-06-01 20:23       ` Junio C Hamano
2015-06-02  1:26         ` Greg KH [this message]
2015-06-26 19:49         ` Stefan Beller
2015-06-26 20:58           ` Junio C Hamano

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=20150602012614.GD23370@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=gascoar@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sunshine@sunshineco.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;
as well as URLs for NNTP newsgroup(s).