Bug 139209 - can not parse multi-file unified diffs without "diff ...." lines
Summary: can not parse multi-file unified diffs without "diff ...." lines
Status: RESOLVED FIXED
Alias: None
Product: kompare
Classification: Applications
Component: parser (show other bugs)
Version: 3.4
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Kompare developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-25 16:23 UTC by Olivier Trichet
Modified: 2009-10-11 19:06 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch (648 bytes, patch)
2006-12-25 16:27 UTC, Olivier Trichet
Details
Correction for r1028720 and r1028515 (472 bytes, patch)
2009-10-11 14:51 UTC, Will Angenent
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Trichet 2006-12-25 16:23:49 UTC
Version:           3.4 (using KDE 3.5.5, Debian Package 4:3.5.5a.dfsg.1-5 (4.0))

Imported bug from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=358853

when reading a unified diff file that comprises diffs to more than one file,
kompare fails to decode it correctly when the leading "diff ...." line is
not given.

Examples:

--- empty1.txt  2006-03-24 20:03:07.000000000 +0100
+++ text1.txt   2006-03-24 20:02:00.000000000 +0100
@@ -0,0 +1 @@
+just a little text
--- empty2.txt  2006-03-24 20:03:07.000000000 +0100
+++ text2.txt   2006-03-24 20:02:22.000000000 +0100
@@ -0,0 +1 @@
+and another text

fails while

diff -ub empty1.txt text1.txt
--- empty1.txt  2006-03-24 20:03:07.000000000 +0100
+++ text1.txt   2006-03-24 20:02:00.000000000 +0100
@@ -0,0 +1 @@
+just a little text
diff -ub empty2.txt text2.txt
--- empty2.txt  2006-03-24 20:03:07.000000000 +0100
+++ text2.txt   2006-03-24 20:02:22.000000000 +0100
@@ -0,0 +1 @@
+and another text

works.
Comment 1 Olivier Trichet 2006-12-25 16:27:46 UTC
Created attachment 19030 [details]
patch

This patch forces the parsing to consider unified header line not to be part of
remove/add lines.
Comment 2 Raúl 2007-11-15 17:55:12 UTC
I have applied the patch to latest Debian packages(3.5.8). It works.
This means that https://bugs.kde.org/show_bug.cgi?id=152366 is a dupe of this one.
Comment 3 Otto Bruggeman 2009-03-11 01:09:36 UTC
SVN commit 938013 by bruggie:

BUG: 139209 This is the best approach to fixing this bug. Thanks to Olivier Trichet for supplying the patch 2 years and almost 3 months ago :(. Sorry for this incredible long time.

 M  +3 -1      parserbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=938013
Comment 4 Kevin Kofler 2009-03-25 00:55:44 UTC
SVN commit 944068 by kkofler:

CCBUG: 139209 This is the best approach to fixing this bug. Thanks to Olivier Trichet for supplying the patch 2 years and almost 3 months ago :(. Sorry for this incredible long time.

Backport revision 938013 by bruggie from trunk.

 M  +3 -1      parserbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=944068
Comment 5 Jeff Snyder 2009-09-27 15:05:25 UTC
that patch is _not_ the way to fix this bug. the patch has introduced bug 208688, which is (in my estimation) significantly worse. The parser needs to respect the line counts in the diff header instead to avoid reading a diff header as diff content.

https://bugs.kde.org/show_bug.cgi?id=208688

reverting fix, reopening.
Comment 6 Jeff Snyder 2009-09-27 15:05:49 UTC
SVN commit 1028512 by je4d:

Revert the fix for bug 139209 - the fix used caused bug 208688. 139209 needs to be fixed by counting lines instead.
BUG:208688
CCBUG:139209


 M  +1 -3      parserbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1028512
Comment 7 Jeff Snyder 2009-09-27 15:26:50 UTC
SVN commit 1028515 by je4d:

track line counts so that we don't interpret a diff header (--- file...) as a removal if there's nothing separating it from the last hunk of the previous diff.
BUG: 139209


 M  +23 -16    parserbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1028515
Comment 8 Jeff Snyder 2009-09-27 15:38:02 UTC
SVN commit 1028516 by je4d:

port bugfix from trunk:
track line counts so that we don't interpret a diff header (--- file...) as a
removal if there's nothing separating it from the last hunk of the previous
diff.
BUG: 139209



 M  +26 -12    parserbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1028516
Comment 9 Kevin Kofler 2009-09-28 02:27:02 UTC
SVN commit 1028719 by kkofler:

Revert the fix for bug 139209 - the fix used caused bug 208688. 139209 needs to be fixed by counting lines instead.
CCBUG:208688
CCBUG:139209

backport revision 1028512 by je4d from trunk

 M  +1 -3      parserbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1028719
Comment 10 Kevin Kofler 2009-09-28 02:29:45 UTC
SVN commit 1028720 by kkofler:

track line counts so that we don't interpret a diff header (--- file...) as a removal if there's nothing separating it from the last hunk of the previous diff.
CCBUG: 139209
(The correct fix for #139209, which hopefully doesn't cause regressions.)

backport revision 1028515 by je4d from trunk

 M  +23 -16    parserbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1028720
Comment 11 Will Angenent 2009-10-11 14:50:00 UTC
There is a bug in the patch: lineCountA is assigned instead of lineCountB for the destination line count. This would cause a diff like this to fail to parse correctly:
--- foo	2009-10-11 13:41:51.000000000 +0100
+++ bar	2009-10-11 13:41:57.000000000 +0100
@@ -1,7 +1,2 @@
 a
-b
-c
-d
-e
-f
 g

The parsing ends prematurely since there are more deletions than insertions, and kompare only shows the line with 'b' as deleted. I'm attaching a patch to correct this.
Comment 12 Will Angenent 2009-10-11 14:51:37 UTC
Created attachment 37509 [details]
Correction for r1028720 and r1028515
Comment 13 Kevin Kofler 2009-10-11 18:34:55 UTC
Whoops, thanks for spotting this, will apply ASAP.
Comment 14 Kevin Kofler 2009-10-11 18:50:01 UTC
SVN commit 1033954 by kkofler:

Fix typo spotted by Will Angenent (4.3.2 regression).
CCBUG: 139209

 M  +1 -1      parserbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1033954
Comment 15 Kevin Kofler 2009-10-11 18:51:17 UTC
SVN commit 1033955 by kkofler:

Fix typo spotted by Will Angenent (4.3.2 regression).
CCBUG: 139209
backport revision 1033954 from trunk

 M  +1 -1      parserbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1033955
Comment 16 Kevin Kofler 2009-10-11 19:06:48 UTC
Fixed in trunk and 4.3 branch, the fix will be in 4.3.3.

Fixed Fedora packages (kdesdk-4.3.2-2.fc13, kdesdk-4.3.2-2.fc12, kdesdk-4.3.2-2.fc11, kdesdk-4.3.2-2.fc10) now building.

Distros are strongly encouraged to apply the fix ASAP.

Thanks again!