Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-07-30 14:01:51 -0400
committerThomas Wolf2019-08-15 15:50:57 -0400
commita2571755340979bc9bfd895fa3f5058da2b2ec8f (patch)
treecef6143c637ee56a08192af50a45342ca418488d /org.eclipse.egit.ui/src/org/eclipse
parent13ae584b2a99f56e19a10e0f1ecc3b9a07d2e9ad (diff)
downloadegit-a2571755340979bc9bfd895fa3f5058da2b2ec8f.tar.gz
egit-a2571755340979bc9bfd895fa3f5058da2b2ec8f.tar.xz
egit-a2571755340979bc9bfd895fa3f5058da2b2ec8f.zip
History: show diffs for merges in first-parent mode
When the history is filtered to show only first parents of merges, use a simple file diff against that single first merge parent to show the list of changes files, and make sure the diff is shown when a file is selected. Change-Id: If2f5f2a7cdd86515190b7d1619c58bd6883520b4 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffInput.java18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java9
3 files changed, 33 insertions, 10 deletions
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 7b5f8dfc0..d6be435af 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
@@ -509,6 +509,8 @@ public class CommitFileDiffViewer extends TableViewer {
FileDiffInput newInput = (FileDiffInput) input;
if (!Objects.equals(realInput.getRepository(),
newInput.getRepository())
+ || realInput.isFirstParentOnly() != newInput
+ .isFirstParentOnly()
|| !realInput.getCommit()
.equals(newInput.getCommit())) {
setSelection(StructuredSelection.EMPTY);
@@ -744,9 +746,17 @@ public class CommitFileDiffViewer extends TableViewer {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
- diffs = FileDiff.compute(input.getRepository(),
- input.getTreeWalk(), input.getCommit(), monitor,
- filter);
+ if (input.isFirstParentOnly()
+ && input.getCommit().getParentCount() > 1) {
+ RevCommit[] parents = { input.getCommit().getParent(0) };
+ diffs = FileDiff.compute(input.getRepository(),
+ input.getTreeWalk(), input.getCommit(), parents,
+ monitor, filter);
+ } else {
+ diffs = FileDiff.compute(input.getRepository(),
+ input.getTreeWalk(), input.getCommit(), monitor,
+ filter);
+ }
} catch (IOException err) {
Activator.handleError(MessageFormat.format(
UIText.CommitFileDiffViewer_errorGettingDifference,
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffInput.java
index 4a0004d1c..14fe989f6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2018, Thomas Wolf <thomas.wolf@paranor.ch>
+ * Copyright (C) 2018, 2019 Thomas Wolf <thomas.wolf@paranor.ch>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -33,6 +33,8 @@ public class FileDiffInput {
private final boolean selectMarked;
+ private final boolean firstParentOnly;
+
/**
* Creates a new {@link FileDiffInput}.
*
@@ -41,11 +43,14 @@ public class FileDiffInput {
* @param commit
* @param interestingPaths
* @param selectMarked
+ * @param firstParentOnly
*/
public FileDiffInput(Repository repository, TreeWalk walk, RevCommit commit,
- Collection<String> interestingPaths, boolean selectMarked) {
+ Collection<String> interestingPaths, boolean selectMarked,
+ boolean firstParentOnly) {
this.commit = commit;
this.selectMarked = selectMarked;
+ this.firstParentOnly = firstParentOnly;
this.repository = repository;
this.walk = walk;
this.interestingPaths = interestingPaths;
@@ -59,6 +64,13 @@ public class FileDiffInput {
}
/**
+ * @return whether the diffs shall be computed against the first parent only
+ */
+ public boolean isFirstParentOnly() {
+ return firstParentOnly;
+ }
+
+ /**
* @return whether the first marked entry shall be selected
*/
public boolean isSelectMarked() {
@@ -88,7 +100,7 @@ public class FileDiffInput {
/**
* Sets the interesting paths.
- *
+ *
* @param interestingPaths
* to set; may be {@code null} or empty
*/
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index 1e33ac4c3..8d5519a5c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -8,7 +8,7 @@
* Copyright (C) 2012-2013 Robin Stocker <robin@nibor.org>
* Copyright (C) 2012, Fran├žois Rey <eclipse.org_@_francois_._rey_._name>
* Copyright (C) 2015, IBM Corporation (Dani Megert <daniel_megert@ch.ibm.com>)
- * Copyright (C) 2015-2018 Thomas Wolf <thomas.wolf@paranor.ch>
+ * Copyright (C) 2015-2019 Thomas Wolf <thomas.wolf@paranor.ch>
* Copyright (C) 2015-2017, Stefan Dirix <sdirix@eclipsesource.com>
*
* All rights reserved. This program and the accompanying materials
@@ -1620,6 +1620,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
return;
}
commentViewer.setInput(c);
+ boolean firstParentOnly = isShowFirstParentOnly();
try (RevWalk walk = new RevWalk(input.getRepository())) {
final RevCommit unfilteredCommit = walk.parseCommit(c);
for (RevCommit parent : unfilteredCommit.getParents())
@@ -1627,11 +1628,11 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
fileViewer.newInput(new FileDiffInput(input.getRepository(),
fileDiffWalker, unfilteredCommit,
fileViewerInterestingPaths,
- input.getSingleFile() != null));
+ input.getSingleFile() != null, firstParentOnly));
} catch (IOException e) {
fileViewer.newInput(new FileDiffInput(input.getRepository(),
fileDiffWalker, c, fileViewerInterestingPaths,
- input.getSingleFile() != null));
+ input.getSingleFile() != null, firstParentOnly));
}
}
});
@@ -2797,7 +2798,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
diffs.size());
for (FileDiff diff : diffs) {
if (progress.isCanceled()
- || diff.getCommit().getParentCount() > 1
+ || diff.getBlobs().length > 2
|| document.getNumberOfLines() > maxLines) {
break;
}

Back to the top