Bug 277078

Summary: Kompare does not work well with git patches
Product: [Applications] kompare Reporter: Konstantin Tokarev <annulen>
Component: generalAssignee: Kompare developers <kompare-devel>
Status: CONFIRMED ---    
Severity: normal CC: annulen
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:

Description Konstantin Tokarev 2011-07-04 16:55:02 UTC
Version:           unspecified (using Devel) 
OS:                Linux

When opening git pathc, Kompare shows error "The diff is malformed. Some lines could not be parsed and will not be displayed in the diff view." 

Also, Kompare shows dummy a/ and b/ prefixes as directories.

Also, Kompare recognizes git patches as "application/mbox" files, and MIME-type-based logic does not work for them ("text/x-patch" is expected)

Reproducible: Didn't try

Steps to Reproduce:
Open any git patch

Actual Results:  
Error about malformed patch is shown. Git patch is not visualized in optimal way

Expected Results:  
Better support for git patches
Comment 1 Kevin Kofler 2011-07-05 09:40:54 UTC
Yes, the check for diff validity is still too strict, even after the fix for bug #249976. :-(
Comment 2 Konstantin Tokarev 2011-07-05 09:42:19 UTC
I think it should work the next way:

1) If file is recognized  as "application/mbox"? search for "diff --git" inside. If found, strip "mail" part and parse remaining diff
Comment 3 Kevin Kofler 2011-07-05 09:45:57 UTC
I don't think the mail prefix is what's causing the "malformed" warning, it's some other non-diff junk, probably the git version at the end.
Comment 4 Konstantin Tokarev 2011-07-05 10:00:32 UTC
If so, strip everything outside "---" guards:

<Mail header>
---
<Actual patch here>
---
<git version>