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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 1, 2015, 18:31 UTC
Message-ID
<xmqqwpzn5lht.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150601001759.GA3934@kroah.com>
Greg KH <gregkh@linuxfoundation.org> writes:
Show 5 quoted lines
> But, there's nothing in the patch at all except the commit message:
>
> $ git show HEAD
> ...
> Any ideas what is going on here?  Shouldn't 'git am' have failed?
Yes.  The patch reads like this:
    ---
     drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/...
    index d2e8b12..0477ba1 100644
    --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
    +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
    @@ -660,2 +660,2 @@ inline struct sk_buff *ieee80211_authentic...
            auth = (struct ieee80211_authentication *)
                    skb_put(skb, sizeof(struct ieee80211_authentication));
    -	auth->header.frame_ctl = IEEE80211_STYPE_AUTH;
    -	if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP;
    +	auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
    +	if (challengelen)
    +		auth->header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_WEP);
            auth->header.duration_id = 0x013a; //FIXME
    --
    2.1.4
    _______________________________________________
    devel mailing list
    devel@linuxdriverproject.org
    http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

It claims that it has only 2 lines in the hunk, so "git apply" parses the hunk that begins at line 660 as such:

    @@ -660,2 +660,2 @@ inline struct sk_buff *ieee80211_authentic...
            auth = (struct ieee80211_authentication *)
                    skb_put(skb, sizeof(struct ieee80211_authentication));

And then seeing that the next line (which is a blank line, not even a lone SP on it) does not begin with "@@ -", it says "OK, the remainder is a cruft after the patch" and discards the rest (which it must be capable of, to ignore "-- ", "2.1.4", "devel mailing list", etc.)

There is some safety against not finding a correct patch header (i.e. "diff --git" line) by detecting a lone "@@ -" while parsing the patch stream, but there is no logic implemented to detect this kind of breakage in the code.

Previous: Christian CouderNext: Junio C Hamano
Message 4 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.