Bug 131717 - kompare won't parse diffs from git
Summary: kompare won't parse diffs from git
Status: RESOLVED FIXED
Alias: None
Product: kompare
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Kompare developers
URL:
Keywords:
: 116637 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-02 12:06 UTC by Andy Parkins
Modified: 2006-08-31 08:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Parkins 2006-08-02 12:06:11 UTC
Version:            (using KDE KDE 3.5.3)
Installed from:    Debian testing/unstable Packages

Kompare just shows blank for diffs redirected from git.

I've tracked down the cause and it seems to be on the file declaration lines.  Here is a sample diff that kompare will not show.

diff --git a/file b/file
index a8b2ec6..a1e65fd 100644
--- a/file
+++ b/file
@@ -1,2 +1,3 @@
 initial contents goes in master branch
 additional content added in repo1#master
+blah

As you can see, it's a simple addition of the line "blah".  Kompare shows this diff as blank.  Now if I modify the file so that the "---" and "+++" lines both have "<tab>(something)" added:

diff --git a/file b/file
index a8b2ec6..a1e65fd 100644
--- a/file      (anything can go here)
+++ b/file      (anything can go here)
@@ -1,2 +1,3 @@
 initial contents goes in master branch
 additional content added in repo1#master
+blah

Kompare will correctly show this diff.
Comment 1 Winfried Dobbe 2006-08-12 12:59:48 UTC
What kind off diff are you using? When I try to reproduce:

diff --git kb.txt kb1.txt
diff: unrecognized option `--git'
diff: Try `diff --help' for more information.

diff -v
diff (GNU diffutils) 2.8.7
Written by Paul Eggert, Mike Haertel, David Hayes,
Richard Stallman, and Len Tower.
Comment 2 Andy Parkins 2006-08-12 13:15:51 UTC
Sorry, I've just realised that I wasn't clear.  Those quotes aren't diff command lines they are output from commands like

$ git diff

That is to say, http://git.or.cz/ the version control system.

The "diff --git" lines are part of git's diff output - not a command line.  To help you reproduce, try the following after installing git (apt-get install git-core)

$ mkdir temp; cd temp
$ git init-db
$ echo "some text" > somefile
$ git add somefile
$ git commit -a -m "Commit a file"
$ echo "some changed text" > somefile
$ git diff
diff --git a/somefile b/somefile
index 7b57bd2..1737c03 100644
--- a/somefile
+++ b/somefile
@@ -1 +1 @@
-some text
+some changed text
$ git diff | kompare -

After that last call, kompare just shows a blank page.

Hope that describes the problem in a more understandable way :-)
Comment 3 Jeff Snyder 2006-08-12 13:55:56 UTC
I think it's because kompare's parser expects the timestamps & whatnot on the ---/+++ lines. I think this bug is a dupe, but I can't remember what the title of the other one is.

- Jeff
Comment 4 Dirk Stoecker 2006-08-30 08:44:44 UTC
*** Bug 116637 has been marked as a duplicate of this bug. ***
Comment 5 Dirk Stoecker 2006-08-31 08:16:59 UTC
SVN commit 579134 by stoecker:

BUG: 131717
Fixed trouble with missing timestamps from git diff (patch by Robin Rosenberg).


 M  +2 -2      branches/KDE/3.5/kdesdk/kompare/libdiff2/parserbase.cpp  
 M  +2 -2      trunk/KDE/kdesdk/kompare/libdiff2/parserbase.cpp  


--- branches/KDE/3.5/kdesdk/kompare/libdiff2/parserbase.cpp #579133:579134
@@ -63,8 +63,8 @@
 	m_normalHunkBodyAdded.setPattern    ( "> (.*)" );
 	m_normalHunkBodyDivider.setPattern  ( "---" );
 
-	m_unifiedDiffHeader1.setPattern    ( "--- ([^\\t]+)\\t([^\\t]+)(?:\\t?)(.*)\\n" );
-	m_unifiedDiffHeader2.setPattern    ( "\\+\\+\\+ ([^\\t]+)\\t([^\\t]+)(?:\\t?)(.*)\\n" );
+	m_unifiedDiffHeader1.setPattern    ( "--- ([^\\t]+)(?:\\t([^\\t]+)(?:\\t?)(.*))?\\n" );
+	m_unifiedDiffHeader2.setPattern    ( "\\+\\+\\+ ([^\\t]+)(?:\\t([^\\t]+)(?:\\t?)(.*))?\\n" );
 	m_unifiedHunkHeader.setPattern     ( "@@ -([0-9]+)(|,([0-9]+)) \\+([0-9]+)(|,([0-9]+)) @@(?: ?)(.*)\\n" );
 	m_unifiedHunkBodyAdded.setPattern  ( "\\+(.*)" );
 	m_unifiedHunkBodyRemoved.setPattern( "-(.*)" );
--- trunk/KDE/kdesdk/kompare/libdiff2/parserbase.cpp #579133:579134
@@ -63,8 +63,8 @@
 	m_normalHunkBodyAdded.setPattern    ( "> (.*)" );
 	m_normalHunkBodyDivider.setPattern  ( "---" );
 
-	m_unifiedDiffHeader1.setPattern    ( "--- ([^\\t]+)\\t([^\\t]+)(?:\\t?)(.*)\\n" );
-	m_unifiedDiffHeader2.setPattern    ( "\\+\\+\\+ ([^\\t]+)\\t([^\\t]+)(?:\\t?)(.*)\\n" );
+	m_unifiedDiffHeader1.setPattern    ( "--- ([^\\t]+)(?:\\t([^\\t]+)(?:\\t?)(.*))?\\n" );
+	m_unifiedDiffHeader2.setPattern    ( "\\+\\+\\+ ([^\\t]+)(?:\\t([^\\t]+)(?:\\t?)(.*))?\\n" );
 	m_unifiedHunkHeader.setPattern     ( "@@ -([0-9]+)(|,([0-9]+)) \\+([0-9]+)(|,([0-9]+)) @@(?: ?)(.*)\\n" );
 	m_unifiedHunkBodyAdded.setPattern  ( "\\+(.*)" );
 	m_unifiedHunkBodyRemoved.setPattern( "-(.*)" );