Bug 544510 - Add support to compare two commits using a unified diff
Summary: Add support to compare two commits using a unified diff
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 10
: P3 enhancement (vote)
Target Milestone: 5.7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-16 09:16 EST by Gayan Perera CLA
Modified: 2020-02-23 13:15 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gayan Perera CLA 2019-02-16 09:16:27 EST
To comparing two file in the git log opens up the compare view which opens in side by side view mode. Its good to provide a unified view as another option so that use can configure which view to use depending on the situations.

Sometime the unified diff view make sense when we have 90% rotated monitors for viewing code files with lot of lines, this makes a ideal candidate for view large patches as well.
Comment 1 Thomas Wolf CLA 2019-02-16 10:57:20 EST
I presume you mean the git history.

There are ways to see a unified diff:

1. Select the commit, then select a file in the bottom right list of files changed in that commit. Shows bottom left, below the commit message, a unified diff of the changes (limited to 10000 lines).

Or

2. Open the the commit in the Commit Viewer (via the context menu), then switch to the "Diff" tab. This shows a unified diff over all changes done in that commit.

Do these two possibilities fulfill your needs?
Comment 2 Gayan Perera CLA 2019-02-17 12:43:30 EST
I actually aware of those two options. I was suggesting for the scenario you select two revisions from log and compare each other.
Comment 3 Thomas Wolf CLA 2019-02-18 05:55:48 EST
Sorry, I didn't understand that from your initial description. Changed the title of this enhancement request.
Comment 4 Mickael Istria CLA 2019-08-05 09:35:50 EDT
The compare editor was a bit improved for Git diff case. Can you please give a try to a recent build of Platform and see whether this change makes this request still relevant.
PS: you mention "comparing 2 commits" and "comparing 2 files", those are different stories, so if it makes sense, please fix the bug title.
Comment 5 Gayan Perera CLA 2019-08-05 10:42:53 EDT
I mean comparing two commits which are not continuous, and right click and select "Compare with Each Other", We should be able to choose which kind of comparison viewer which should be use like "side by side" or "unified".
Comment 6 Gayan Perera CLA 2019-08-05 10:43:31 EDT
I think if we have the viewer, comparing two files might be trivial to implement.
Comment 7 Alexander Nittka CLA 2020-02-02 07:07:00 EST
I implemented a quick and dirty version for our immediate requirements (https://github.com/nittka/egit-extensions/commit/3a15bd9b999e7ad7e8f5df1e9067bb1017362a2e) and usage.
When two commits are selected in the history view a third compare with each other menu item is shown. The existing DiffViewer is reused as s source viewer for a new editor with corresponding dummy editor input.

I'd like this feature to be part of EGit but I am not quite sure yet, whether it should be a different view/editor or whether an existing one should be generalized. Hence the external proof of concept.

This enhancement request may also be related to bug 550673.
Comment 8 Thomas Wolf CLA 2020-02-02 09:09:57 EST
(In reply to Alexander Nittka from comment #7)
> I implemented a quick and dirty version for our immediate requirements
> (https://github.com/nittka/egit-extensions/commit/
> 3a15bd9b999e7ad7e8f5df1e9067bb1017362a2e) and usage.
> When two commits are selected in the history view a third compare with each
> other menu item is shown. The existing DiffViewer is reused as s source
> viewer for a new editor with corresponding dummy editor input.
> 
> I'd like this feature to be part of EGit but I am not quite sure yet,
> whether it should be a different view/editor or whether an existing one
> should be generalized. Hence the external proof of concept.
> 
> This enhancement request may also be related to bug 550673.

It would certainly be nice if the TextEditor stuff from DiffEditorPage could be extracted and re-used. Similar for the associated outline page. I also think modern Eclipses have some support in GenericEditor for patch/diff files. (But I don't think it has our hyperlinking, and I don't know about its syntax coloring.)
Comment 9 Eclipse Genie CLA 2020-02-12 06:11:36 EST
New Gerrit change created: https://git.eclipse.org/r/157560
Comment 10 Eclipse Genie CLA 2020-02-12 06:11:39 EST
New Gerrit change created: https://git.eclipse.org/r/157561
Comment 11 Eclipse Genie CLA 2020-02-12 06:11:42 EST
New Gerrit change created: https://git.eclipse.org/r/157563
Comment 12 Eclipse Genie CLA 2020-02-12 06:11:50 EST
New Gerrit change created: https://git.eclipse.org/r/157562
Comment 13 Eclipse Genie CLA 2020-02-12 06:11:58 EST
New Gerrit change created: https://git.eclipse.org/r/157565
Comment 14 Eclipse Genie CLA 2020-02-12 06:12:01 EST
New Gerrit change created: https://git.eclipse.org/r/157564
Comment 15 Eclipse Genie CLA 2020-02-12 06:12:04 EST
New Gerrit change created: https://git.eclipse.org/r/157566
Comment 16 Thomas Wolf CLA 2020-02-12 06:16:17 EST
(In reply to Thomas Wolf from comment #8)
> It would certainly be nice if the TextEditor stuff from DiffEditorPage could
> be extracted and re-used. Similar for the associated outline page.

This series of commits does that, and adds "Show Unified Diff" commands to the history, reflog, and interactive rebase views. Adding comparisons between two refs selected in the repositories view is not done; that's the subject of bug bug 550673.
Comment 17 Eclipse Genie CLA 2020-02-16 17:28:12 EST
Gerrit change https://git.eclipse.org/r/157560 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=f5520ec96045cd64b1f807fa57c5a88483a9a7d7
Comment 18 Eclipse Genie CLA 2020-02-16 17:28:15 EST
Gerrit change https://git.eclipse.org/r/157561 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=bf86d9efd911693ec87b2694393f5f7de1fa70ba
Comment 19 Eclipse Genie CLA 2020-02-23 12:14:54 EST
Gerrit change https://git.eclipse.org/r/157566 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=9c4273f90c547b741895b2cbd8953824779da746
Comment 20 Eclipse Genie CLA 2020-02-23 12:14:57 EST
Gerrit change https://git.eclipse.org/r/157565 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=6aa02c69fbf239eb1d7d69dbafc3c360df37c10a
Comment 21 Eclipse Genie CLA 2020-02-23 12:14:59 EST
Gerrit change https://git.eclipse.org/r/157564 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=bda50a6bacc6af13e7dd5a7107140e2bf6dd8b19
Comment 22 Eclipse Genie CLA 2020-02-23 12:15:02 EST
Gerrit change https://git.eclipse.org/r/157563 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=b766c0a7c003940505e3fb16d327b10db974559b
Comment 23 Eclipse Genie CLA 2020-02-23 12:15:05 EST
Gerrit change https://git.eclipse.org/r/157562 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=b1d2bba6ac28a8399ba5abd9aaefb41456c3d9f3