From: Jeff King <peff@peff.net>
To: tuxdna <tuxdna@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Bug: fatal: patch fragment without header at line
Date: Tue, 17 Jul 2012 00:21:37 -0400 [thread overview]
Message-ID: <20120717042137.GE20945@sigill.intra.peff.net> (raw)
In-Reply-To: <CAK5QfLMs6CMCTtZ3woQfMim1ssYLKEURAMv8+FgqrKJ7otNcnw@mail.gmail.com>
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
prev parent reply other threads:[~2012-07-17 4:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-16 13:36 Bug: fatal: patch fragment without header at line tuxdna
2012-07-16 17:19 ` Junio C Hamano
2012-07-17 4:21 ` Jeff King [this message]
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=20120717042137.GE20945@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=tuxdna@gmail.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).