summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate Case <ncase@xes-inc.com>2008-10-20 11:31:11 -0500
committerJeremy Kerr <jk@ozlabs.org>2008-10-23 14:27:10 +1100
commit6cf42625073d11bd63adc681a4d141a932925d0e (patch)
tree5a0f1227dff58314680392fdbb3a7a2a4a5f4cfd
parentd45218b2e3894211e11313820bea9f59677c4bf2 (diff)
downloadpatchwork-6cf42625073d11bd63adc681a4d141a932925d0e.tar.bz2
patchwork-6cf42625073d11bd63adc681a4d141a932925d0e.tar.xz
[parser] Handle special case of "New newline at end of file"
If a file doesn't have a newline at the end, diff will insert a "\ No newline at end of file" line in the middle of the last hunk. parser.py was counting this line as part of the hunk line count. This had the side effect of putting the last line of the hunk in the patch comment, and truncating out the last line of the diff. Handle this special case by not including this line in the internal line counter. This appears to be the only case where diff will insert a string like this within a hunk. Signed-off-by: Nate Case <ncase@xes-inc.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--apps/patchwork/parser.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/apps/patchwork/parser.py b/apps/patchwork/parser.py
index abec782..16cc308 100644
--- a/apps/patchwork/parser.py
+++ b/apps/patchwork/parser.py
@@ -133,6 +133,9 @@ def parse_patch(text):
lc[0] -= 1
elif line.startswith('+'):
lc[1] -= 1
+ elif line.startswith('\ No newline at end of file'):
+ # Special case: Not included as part of the hunk's line count
+ pass
else:
lc[0] -= 1
lc[1] -= 1