[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-patch] patch-2.5.9 - patch.c:340: main: Assertion `hunk' failed.
From: |
Alexander Lamaison |
Subject: |
[bug-patch] patch-2.5.9 - patch.c:340: main: Assertion `hunk' failed. |
Date: |
Mon, 1 Jun 2009 12:42:08 +0100 |
While transforming the patch code into a reusable library, I came
across a bug that is also present in the mainstream patch code.
When given an input appears to be a standard diff but has inconsistent
indentation (attached as test_data), intuit_diff_type() returns
NORMAL_DIFF as the type and sets the second line's indentation as the
indent for the whole file. there_is_another_patch() continues to
process the file but fails to find any hunks, presumably, because it
gets confused by the indentation. Eventually this causes the
following assertion:
$ ./patch --dry-run < test_input
can't find file to patch at input line 1
Perhaps you should have used the -p or --strip option?
File to patch: patch
patching file patch
patch: patch.c:340: main: Assertion `hunk' failed.
Aborted
I've attached a patch that forces intuit_diff_type() to return NO_DIFF
when it finds that the indentation is inconsistent between the first
two lines of a standard diff. I'm sure that there is a more graceful
way to handle this situation but I don't yet understand enough of the
code to find it. My priority in making a library was to prevent any
code path that could lead to termination.
patch 2.5.9
gcc 4.2.4
Ubuntu Linux 8.04 Hardy Heron
x64
Hope this helps.
Alex Lamaison
--
http://www.doc.ic.ac.uk/~awl03
test_input
Description: Binary data
inconsistent_indent.patch
Description: Text Data
- [bug-patch] patch-2.5.9 - patch.c:340: main: Assertion `hunk' failed.,
Alexander Lamaison <=