Bug 204253 - kompare has troubles parsing certain unified diff output
Summary: kompare has troubles parsing certain unified diff output
Status: RESOLVED DUPLICATE of bug 208688
Alias: None
Product: kompare
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Kompare developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-18 10:56 UTC by Markus Schöpflin
Modified: 2009-09-27 15:44 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fix parsing of unified diffs (3.86 KB, patch)
2009-08-19 12:05 UTC, Markus Schöpflin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Schöpflin 2009-08-18 10:56:21 UTC
Version:           3.5.4 (using KDE 4.2.4)
OS:                Linux
Installed from:    Ubuntu Packages

When diffing the following two files, kompare comes up with an empty window. Looks like kompare is confused by the triple minus in the diff output.

$ kompare -v
Qt: 4.5.0
KDE: 4.2.2 (KDE 4.2.2)
Kompare: 3.5.4
$ cat a_1
-- foo
$ cat a_2
-- bar
$ diff -u a_1 a_2
--- a_1 2009-08-18 10:42:02.000000000 +0200
+++ a_2 2009-08-18 10:42:07.000000000 +0200
@@ -1 +1 @@
--- foo
+-- bar
$ diff -u a_1 a_2 | kompare -
Comment 1 Markus Schöpflin 2009-08-18 10:58:46 UTC
Please note that this report is actually for KDE 4.2.2 for which I couldn't file a bug. As I have no means to try it with a more recent version of KDE, someone would need to verify if it is indeed broken on 4.2.4.
Comment 2 Kevin Kofler 2009-08-18 12:00:38 UTC
It almost certainly is, we didn't do anything to fix it in the 4.2 branch before 4.2.4 or in the 4.3 branch before 4.3.0 (nor is this fixed in the current 4.3 branch or trunk as far as I know).
Comment 3 Markus Schöpflin 2009-08-18 13:13:42 UTC
I had a look at the sources for kompare. The problem seems to be that ParserBase::parseUnifiedHunkBody() stops reading the hunk body as soon as it finds a line matching m_unifiedDiffHeader1 (e.g. '--- blahblah'). This happens because ParserBase::matchesUnifiedHunkLine() returns False for such lines.

I think the parsing of the hunk body must take into account the full information from the hunk header, because otherwise you cannot reliably tell where the hunk body ends.
Comment 4 Markus Schöpflin 2009-08-19 12:05:45 UTC
Created attachment 36277 [details]
Fix parsing of unified diffs

This patch for libdiff2 modifies the parsing of unified diffs to take into account the full information given in the diff header. Now kompare correctly displays the unified diff example I gave earlier.
Comment 5 Otto Bruggeman 2009-08-19 13:09:06 UTC
Patch looks sane. Can someone confirm that this fixes the bug with this testcase? I dont have a working KDE atm. Please also add this testcase for this bug to the testcases in kompare so we can make sure this bug does not return.

Thank you very much for reporting the bug and for the patch!
Comment 6 Kevin Kofler 2009-09-27 15:44:00 UTC

*** This bug has been marked as a duplicate of bug 208688 ***