Re: Bug: fatal: patch fragment without header at line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 16, 2012 at 07:06:51PM +0530, tuxdna wrote:

> Git version: git-1.7.7.6-1.fc16.x86_64
> 
> I am getting an error with a patch that I am applying to a git repository.
> I have created a test case for this issue that I am facing.
> 
> $ git apply --check 0001-modified-README.patch
> fatal: patch fragment without header at line 7: @@ -635,9 +635,7 @@
> some_function()
> 
> Clearly line 7 appears to be a patch but it isn't. It is the part of
> email body or the patch context.
> To my understanding, the patch should always be identified whenever
> the patch block starts
> with a "diff --git", which is line 21 as below:

It is identified properly when you use "git am" to apply your patch. It
will use "git mailinfo" to split on the "---" and feed only the bottom
half to "git apply". But as a low-level tool, "git apply" looks for a
patch immediately, and does not know anything about the "---" line. It
is correct to diagnose a possibly broken patch.

> Apart from changing the patch itself, how else can I work-around this problem?

Run "git am 0001-modified-README.patch" to parse it correctly. If for
some reason you really do not want to make a commit (e.g., you are going
to squash-apply a bunch of patches together), then either:

  1. Don't use format-patch to generate the patch. Use "git diff-tree",
     which will omit the commit message (which "git apply" would just
     inore anyway).

  2. Use "git mailinfo" to split the patch out of the email format
     generated by format-patch, and then "git apply" the result.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]