Bug 554878

Summary: unified patch view incorrectly displays git diffs
Product: [Community] Bugzilla Reporter: Bill Nottingham <notting>
Component: Attachments/RequestsAssignee: PnT DevOps Devs <hss-ied-bugs>
Status: CLOSED DUPLICATE QA Contact: tools-bugs <tools-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 4.4CC: dondyabla, fweimer, mnewsome, mtahir, mtyson, pbonzini, prarit, rjones, rvokal, ville.skytta
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-19 09:41:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bill Nottingham 2010-01-12 21:33:27 UTC
Description of problem:

Compare:
https://bugzilla.redhat.com/attachment.cgi?id=379446
with:
https://bugzilla.redhat.com/attachment.cgi?id=379446&action=diff&context=patch&collapsed=&headers=1&format=raw

The comments/context at the top of the patch is important to keep around.

Version-Release number of selected component (if applicable):

bz-current

How reproducible:

100%

Comment 1 Ville Skyttä 2010-03-12 18:58:11 UTC
It is not only the context/headers/comments that are lost in some cases but bits of actual patch content as well.  This is reported against 3.6 but I'm currently (I believe) using 3.4.6 and it happens with it too.

Compare:
https://bugzilla.redhat.com/attachment.cgi?id=399519

With:
https://bugzilla.redhat.com/attachment.cgi?id=399519&action=diff
https://bugzilla.redhat.com/attachment.cgi?id=399519&action=diff&context=patch&collapsed=&headers=1&format=raw

The actual patch contains these two lines:

+-            s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\1/p" \
++            s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \

Only the first of these is shown by the diff viewer, the second is missing.

Comment 2 Jeff Fearn 🐞 2012-05-30 04:35:57 UTC
As part of the recent Bugzilla 2.4 upgrade the Bugzilla team are cleaning up bugs opened against old versions of Bugzilla. This bug has been flagged as an old bug and will be CLOSED WONTFIX in 7 days time.

If you believe this bug is an issue in the latest Bugzilla version please comment on this bug within 7 days. Doing so will ensure this bug is not closed automatically.

Thanks, the Bugzilla team.

Comment 3 Simon Green 2012-05-30 13:21:38 UTC
This was fixed in Bugzilla 4.2

Comment 4 Ville Skyttä 2012-05-30 14:22:45 UTC
(In reply to comment #3)
> This was fixed in Bugzilla 4.2

It is not fixed, the test case described in comment 1 still fails - the mentioned second line of patch content is still missing.

Comment 5 Simon Green 2012-06-20 03:02:40 UTC
*** Bug 562218 has been marked as a duplicate of this bug. ***

Comment 6 Simon Green 2012-06-21 00:43:13 UTC
*** Bug 708014 has been marked as a duplicate of this bug. ***

Comment 7 Simon Green 2012-06-21 00:43:26 UTC
*** Bug 698594 has been marked as a duplicate of this bug. ***

Comment 8 Jeff Fearn 🐞 2012-06-21 03:53:33 UTC
These bugs have been flagged as still relevant and are being reset to default values for PM consideration.

Comment 9 Matt Tyson 🤬 2012-10-26 04:00:32 UTC
This looks like a bug in the PatchReader library.  It appears it's not designed to cope with nested patches, or anything that has patch-like syntax scattered about where it would not normally be expected in a standard patch.

Comment 10 Matt Tyson 🤬 2012-10-28 23:42:05 UTC
As stated in comment 9, this is a bug in the PatchReader code.

This is not a bug in bugzilla and should be filed upstream with the PatchReader maintainers.

Comment 11 Ville Skyttä 2012-10-29 14:44:38 UTC
What's the version of PatchReader running at bugzilla.redhat.com? I'm asking because PatchReader 0.9.6's change log shows a couple of things changed that could affect this, and it'd be good to verify this before spending time on trying to create upstream PatchReader reproducers:

0.9.6 4/11/2011
  Add tests to instantiate all modules and verify parsing of patches
  Fix POD syntax
  Fix corruption due to patched lines having a + or - as the first character
  Fix FixPatchRoot w/DOS eol patches (RT bug #35362, regression from v0.9.3)
  Attic file support for FixPatchRoot (RT bug #40467)
  Multiple file patch support (RT bug #47625)

Comment 12 Matt Tyson 🤬 2012-10-29 23:35:07 UTC
You are correct.  PatchReader 0.9.6 fixes this problem.

I've made a test case for comment 1, and that line is not dropped in 0.9.6, but it is dropped in 0.9.5.

As part of the next release we will upgrade PatchReader.

The problem reported in the bug description will still exist, as the email header and Git output is not valid in a patch file.  This information should be put in the attachment description.

Comment 13 Ville Skyttä 2012-10-30 07:20:49 UTC
I believe the mail header and git stuff as well as just about anything is ok to have before the unified diff indicators/headers in patch files. From patch(1):

| patch tries to skip any leading garbage, apply the diff, and then skip any
| trailing garbage.  Thus you could feed an  article  or  message containing
| a  diff listing to patch, and it should work.

Using leading text this way is certainly a common practice and definitely useful there for example for typical git workflows (git am). My understanding is that  the case being discussed in this bug is exactly the "message containing a diff listing" one.

BTW, PatchReader is listed as an optional module "for pretty HTML view of patches" in Bugzilla upstream installation docs - FWIW my opinion is that if it can break/confuse things this way it'd be better to disable it altogether.

Comment 14 Matt Tyson 🤬 2012-11-06 00:22:14 UTC
(In reply to comment #13)
> I believe the mail header and git stuff as well as just about anything is ok
> to have before the unified diff indicators/headers in patch files. From
> patch(1):
> 
> | patch tries to skip any leading garbage, apply the diff, and then skip any
> | trailing garbage.  Thus you could feed an  article  or  message containing
> | a  diff listing to patch, and it should work.
> 
> Using leading text this way is certainly a common practice and definitely
> useful there for example for typical git workflows (git am). My
> understanding is that  the case being discussed in this bug is exactly the
> "message containing a diff listing" one.

Unfortunately PatchReader does not support this.
If you feel this is a bug in PatchReader, then please submit a bug against PatchReader in CPAN's bug tracker.

Comment 15 Richard W.M. Jones 2015-02-06 10:09:53 UTC
Reopening because the bug is real and still not fixed.

Comment 16 Richard W.M. Jones 2015-02-06 10:12:41 UTC
Another example of a broken patch:
https://bugzilla.redhat.com/show_bug.cgi?id=1189894#c4

Comment 17 Jeff Fearn 🐞 2015-02-10 02:11:04 UTC
Bugzilla does not corrupt patches, some of the views of them are incorrect.

e.g. the raw view shows the full patch https://bugzilla.redhat.com/attachment.cgi?id=988596

The module used to show the unified view does not support git syntax. The upstream bug tracker, where RFEs should be lodged, is https://rt.cpan.org/Public/Dist/Display.html?Name=PatchReader

Until the upstream module is enhanced do not use git diff syntax if you want to use the unified diff view.

IMO what we should do is ensure that BZ refuses to display patches via the enhanced views if the format cannot be fully supported.

Comment 18 Jason McDonald 2015-04-08 06:28:40 UTC
As hinted in Comment 1, a diff of diffs doesn't display correctly as reported in Bug 1209721.

Comment 19 Jason McDonald 2015-04-08 06:29:23 UTC
*** Bug 1209721 has been marked as a duplicate of this bug. ***

Comment 20 Jeff Fearn 🐞 2016-09-01 07:15:42 UTC
Might be worth investigating https://foswiki.org/Extensions/DiffPlugin to see if it does what we need and is easy to turn in to a Bugzilla extension.

Comment 21 Florian Weimer 2016-10-14 10:57:06 UTC
*** Bug 1384801 has been marked as a duplicate of this bug. ***

Comment 22 Florian Weimer 2016-10-14 10:59:27 UTC
Perhaps the “raw unified diff” link could be renamed to “raw diff”, and point to the raw attachment download?  This way, the faulty reformatting would no longer be exposed (except for existing hyperlinks).

Comment 23 Jeff Fearn 🐞 2016-10-19 09:41:32 UTC
Closing as a dupe as Bug 738069 replaces the patch viewer with https://diff2html.xyz

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