Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Jeff Garzik <jeff@garzik.org>
Cc: git@vger.kernel.org, Linus Torvalds <torvalds@osdl.org>
Subject: Re: git-am applies half of a patch
Date: Tue, 09 Jan 2007 02:52:31 -0800	[thread overview]
Message-ID: <7vtzz0mpzk.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 45A36D6B.4010303@garzik.org

Jeff Garzik <jeff@garzik.org> writes:

> I ran
>
> 	git-am --signoff --utf8 /g/tmp/mbox
>
> on the attached file, to apply a patch to libata-dev.git#upstream, and
> it wound up only applying a portion of the patch:
>
>> [jgarzik@pretzel libata-dev]$ git-am --signoff --utf8 /g/tmp/mbox
>>
>> Applying 'Add pci class code for SATA AHCI'
>>
>> error: patch fragment without header at line 35: @@ -862,7 +862,7 @@
>> error: patch fragment without header at line 50: @@ -15,6 +15,8 @@
>> Wrote tree 5d6f3a93bea932c950ac880deca173dd3e84dfcc
>> Committed: 317b180bad43133027dc07455f1600f4e8a47d76
>
> It seems quite bad to apply a patch that git-am KNOWS is incomplete.

Quite true.

This turns out to be quite an old bug (dates back to May 2005).
I've scanned builtin-apply.c while coming up with this fix to
see if there other "detected but ignored" errors, but it appears
this is the only one.

Sorry for the trouble and thanks for the report.

-- >8 --
[PATCH] Do not ignore a detected patchfile brokenness.

find_header() function is used to read and parse the patchfile
and it detects errors in the patch, but one place ignored the
error and went ahead, which was quite bad.

Noticed by Jeff Garzik.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/builtin-apply.c b/builtin-apply.c
index 1c35837..918822b 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -811,7 +811,7 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
 			struct fragment dummy;
 			if (parse_fragment_header(line, len, &dummy) < 0)
 				continue;
-			error("patch fragment without header at line %d: %.*s", linenr, (int)len-1, line);
+			return error("patch fragment without header at line %d: %.*s", linenr, (int)len-1, line);
 		}
 
 		if (size < len + 6)

  reply	other threads:[~2007-01-09 10:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-09 10:24 git-am applies half of a patch Jeff Garzik
2007-01-09 10:52 ` Junio C Hamano [this message]
2007-01-09 11:10   ` Jeff Garzik
2007-01-09 16:08   ` Linus Torvalds
2007-01-09 18:12     ` Junio C Hamano
2007-01-09 16:02 ` Linus Torvalds

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=7vtzz0mpzk.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=jeff@garzik.org \
    --cc=torvalds@osdl.org \
    /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