diff options
author | Thomas Wolf | 2019-07-30 18:01:51 +0000 |
---|---|---|
committer | Thomas Wolf | 2019-08-15 19:50:57 +0000 |
commit | a2571755340979bc9bfd895fa3f5058da2b2ec8f (patch) | |
tree | cef6143c637ee56a08192af50a45342ca418488d /org.eclipse.egit.ui/src | |
parent | 13ae584b2a99f56e19a10e0f1ecc3b9a07d2e9ad (diff) | |
download | egit-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')
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 7b5f8dfc06..d6be435af6 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 4a0004d1c8..14fe989f65 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 1e33ac4c36..8d5519a5ca 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; } |