git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug: fatal: patch fragment without header at line
@ 2012-07-16 13:36 tuxdna
  2012-07-16 17:19 ` Junio C Hamano
  2012-07-17  4:21 ` Jeff King
  0 siblings, 2 replies; 3+ messages in thread
From: tuxdna @ 2012-07-16 13:36 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1912 bytes --]

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:

     1	From aa3acc563af0422e6a9f4afc432b7fabdf845d81 Mon Sep 17 00:00:00 2001
     2	From: Saleem Ansari <tuxdna@gmail.com>
     3	Date: Mon, 16 Jul 2012 17:42:58 +0530
     4	Subject: [PATCH] modified README
     5	
     6	
     7	@@ -635,9 +635,7 @@ some_function()
     8	
     9	
    10	-       # a comment here
    11	+       not a comment
    12	
    13	
    14	
    15	thats all folks
    16	
    17	---
    18	 README |    1 +
    19	 1 files changed, 1 insertions(+), 0 deletions(-)
    20	
    21	diff --git a/README b/README
    22	index ce01362..d294257 100644
    23	--- a/README
    24	+++ b/README
    25	@@ -1 +1,2 @@
    26	 hello
    27	+this is a readme
    28	--
    29	1.7.7.6
    30	

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

Steps to create and verify the testcase:

# Create a temporary directory
mkdir /tmp/bug
cd /tmp/bug
git init .
echo "hello" > README
git commit -m "Initial commit"

# create a test branch for verification later
git checkout -b test

# make changes into a different branch
git checkout -b bugger
echo "this is a readme" > README
git commit -m "modified README"
git format-patch HEAD^ # this will generate 0001-modified-README.patch
# Now inside the patch email body add some random patch which should break
# or download the attachment ( 0001-modified-README.patch )

/tuxdna

[-- Attachment #2: 0001-modified-README.patch --]
[-- Type: application/octet-stream, Size: 497 bytes --]

From aa3acc563af0422e6a9f4afc432b7fabdf845d81 Mon Sep 17 00:00:00 2001
From: Saleem Ansari <tuxdna@gmail.com>
Date: Mon, 16 Jul 2012 17:42:58 +0530
Subject: [PATCH] modified README


@@ -635,9 +635,7 @@ some_function()


-       # a comment here
+       not a comment



thats all folks

---
 README |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/README b/README
index ce01362..d294257 100644
--- a/README
+++ b/README
@@ -1 +1,2 @@
 hello
+this is a readme
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-17  4:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).