Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2019-08-04 01:59:49 -0400
committerMichael Keppler2019-08-15 02:50:37 -0400
commitdbd7838aba2f54b28d4d5601f994e70cc2ddab2d (patch)
tree53b3dbd094ef7ffa6e7b58c32f08fbd05fbb506d
parent3742c81bfc1e99c5ecaf558eace056a786e2aeaf (diff)
downloadegit-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>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java12
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java11
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 53adaff7e..fce1d1292 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 793304f40..7b5f8dfc0 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) {

Back to the top