diff options
author | Michael Keppler | 2019-08-04 05:59:49 +0000 |
---|---|---|
committer | Michael Keppler | 2019-08-15 06:50:37 +0000 |
commit | dbd7838aba2f54b28d4d5601f994e70cc2ddab2d (patch) | |
tree | 53b3dbd094ef7ffa6e7b58c32f08fbd05fbb506d /org.eclipse.egit.ui/src/org | |
parent | 3742c81bfc1e99c5ecaf558eace056a786e2aeaf (diff) | |
download | egit-dbd7838aba2f54b28d4d5601f994e70cc2ddab2d.tar.gz egit-dbd7838aba2f54b28d4d5601f994e70cc2ddab2d.tar.xz egit-dbd7838aba2f54b28d4d5601f994e70cc2ddab2d.zip |
Always check for merge commit when opening file diff
The 2-way file diff is invoked from 3 different places in the code, but
only one of them checked whether the diff was a merge commit. Move that
check into the file diff method itself to have all 3 invocations
checked.
It might be possible that the other 2 invocations cannot be called for
merge commits due to other external logic, but let's be fault tolerant
here by always forbidding this.
Change-Id: Ieaacc0c0ddf0bdbc273891cd557ab55ff5560133
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui/src/org')
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java | 12 | ||||
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java | 11 |
2 files changed, 12 insertions, 11 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java index 53adaff7ec..fce1d12926 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java @@ -51,6 +51,7 @@ import org.eclipse.egit.ui.internal.commit.DiffRegionFormatter.FileDiffRegion; import org.eclipse.egit.ui.internal.dialogs.HyperlinkSourceViewer; import org.eclipse.egit.ui.internal.history.FileDiff; import org.eclipse.egit.ui.internal.revision.GitCompareFileRevisionEditorInput; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.ColorRegistry; import org.eclipse.jface.resource.FontRegistry; @@ -797,10 +798,19 @@ public class DiffViewer extends HyperlinkSourceViewer { * the {@link FileDiff} to show */ public static void showTwoWayFileDiff(FileDiff d) { + ObjectId[] blobs = d.getBlobs(); + if (blobs.length > 2) { + MessageDialog.openInformation( + PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(), + UIText.CommitFileDiffViewer_CanNotOpenCompareEditorTitle, + UIText.CommitFileDiffViewer_MergeCommitMultiAncestorMessage); + return; + } + String np = d.getNewPath(); String op = d.getOldPath(); RevCommit c = d.getCommit(); - ObjectId[] blobs = d.getBlobs(); // extract commits final RevCommit oldCommit; diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java index 793304f40d..7b5f8dfc06 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java @@ -60,7 +60,6 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; import org.eclipse.jface.viewers.IOpenListener; @@ -614,15 +613,7 @@ public class CommitFileDiffViewer extends TableViewer { } void showTwoWayFileDiff(final FileDiff d) { - if (d.getBlobs().length <= 2) { - DiffViewer.showTwoWayFileDiff(d); - } else { - MessageDialog.openInformation( - PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(), - UIText.CommitFileDiffViewer_CanNotOpenCompareEditorTitle, - UIText.CommitFileDiffViewer_MergeCommitMultiAncestorMessage); - } + DiffViewer.showTwoWayFileDiff(d); } void showWorkingDirectoryFileDiff(final FileDiff d) { |