Re: git-am applies half of a patch
On Tue, 9 Jan 2007, Jeff Garzik wrote:
Show 17 quoted lines
>
> 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.
It doesn't actually "know" it. What is going on is that the "patch" program generally allows random crap in between multiple patches, and while git-apply is normally stricter than "patch" ever is, git-apply does allow this "garbage between patches" thing too.
Sometimes the garbage is just commentary (some people say things in between patches), but quite often it's also stuff like "Index: " (and in fact, git considers the "diff " line at the head to be "garbage" too, unless it's a native git diff that has the "diff --git" signature).
So what git is actually doing is seeing that you have _garbage_ after the real patch, but then it _warns_ about the garbage containing what looks like a patch fragment. And the reason it's garbage (rather than a real patch) is obviously because your patch was so heavily whitespace-damaged that the header that was supposed to start it wasn't a valid header at all..
But if you'd like to make it fatal, the patch is certainly simple..
Junio - I certainly wouldn't mind making this a fatal error, but it's ultimately your decision.
Linus
---
diff --git a/builtin-apply.c b/builtin-apply.c
index 1c35837..d3fdf7e 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);
+ die("patch fragment without header at line %d: %.*s", linenr, (int)len-1, line);
}
if (size < len + 6)