Skip to content

First context line is discarded from hunk text if it is at the end andon the same line as the hunk "@@ <...> @@" line #22

@GoogleCodeExporter

Description

@GoogleCodeExporter
What version of the product are you using?  HEAD r158

What steps will reproduce the problem?

1.Use this patch (attached too):

See how the first context line is on the hunk header line
{{{
Index: linux-2.6.23/fs/Makefile
===================================================================
--- linux-2.6.23.orig/fs/Makefile
+++ linux-2.6.23/fs/Makefile
@@ -72,7 +72,6 @@ obj-$(CONFIG_JBD)     += jbd/
 obj-$(CONFIG_JBD2)     += jbd2/
 obj-$(CONFIG_EXT2_FS)      += ext2/
 obj-$(CONFIG_CRAMFS)       += cramfs/
-obj-$(CONFIG_SQUASHFS)     += squashfs/
 obj-$(CONFIG_RAMFS)        += ramfs/
 obj-$(CONFIG_HUGETLBFS)        += hugetlbfs/
 obj-$(CONFIG_CODA_FS)      += coda/

}}}

2. Then run this:
{{{
# python -c "import patch;p=patch.fromfile('sample.patch');from pprint import 
pprint as pp;pp( p.items[0].hunks[0].text)"
[' obj-$(CONFIG_JBD2)\t\t+= jbd2/\r\n',
 ' obj-$(CONFIG_EXT2_FS)\t\t+= ext2/\r\n',
 ' obj-$(CONFIG_CRAMFS)\t\t+= cramfs/\r\n',
 '-obj-$(CONFIG_SQUASHFS)\t\t+= squashfs/\r\n',
 ' obj-$(CONFIG_RAMFS)\t\t+= ramfs/\r\n',
 ' obj-$(CONFIG_HUGETLBFS)\t\t+= hugetlbfs/\r\n',
 ' obj-$(CONFIG_CODA_FS)\t\t+= coda/']
}}}

3. The expected results here should be:
{{{
[' obj-$(CONFIG_JBD)\t\t+= jbd/\r\n',
 ' obj-$(CONFIG_JBD2)\t\t+= jbd2/\r\n',
 ' obj-$(CONFIG_EXT2_FS)\t\t+= ext2/\r\n',
 ' obj-$(CONFIG_CRAMFS)\t\t+= cramfs/\r\n',
 '-obj-$(CONFIG_SQUASHFS)\t\t+= squashfs/\r\n',
 ' obj-$(CONFIG_RAMFS)\t\t+= ramfs/\r\n',
 ' obj-$(CONFIG_HUGETLBFS)\t\t+= hugetlbfs/\r\n',
 ' obj-$(CONFIG_CODA_FS)\t\t+= coda/']

}}}
Note that I have no idea how the patch was originally produced. It could have 
been manually edited and could be incorrect. I do not know either if that extra 
line would be used by GNU patch as context line or also discarded.



Original issue reported on code.google.com by pombreda...@nexb.com on 22 Aug 2012 at 1:42

Attachments:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions