Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2019-08-04 09:13:51 -0400
committerMichael Keppler2019-08-21 07:54:18 -0400
commitd000c9dd50d6dff346349a0a0c66a70b5445ba1b (patch)
treef60b3bbce6d7c7656c96f99c7eca5aa4e8584e92 /org.eclipse.egit.ui/src/org/eclipse
parent9a0e6920c9e134d8a7848ca289645e79f9e4d6fa (diff)
downloadegit-d000c9dd50d6dff346349a0a0c66a70b5445ba1b.tar.gz
egit-d000c9dd50d6dff346349a0a0c66a70b5445ba1b.tar.xz
egit-d000c9dd50d6dff346349a0a0c66a70b5445ba1b.zip
Show current branch first in pull result dialog
Branches are sorted by name in the pull result dialog. Make an exception for the current branch, and move it to the top. That way the commits being merged into the current local branch are shown first. Bug: 545044 Change-Id: Ib807f3ce1ab1b0fb57e2eb7b5a81ee7ef80ff3e9 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultTable.java32
1 files changed, 31 insertions, 1 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultTable.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultTable.java
index 682aafcc9..9b608e983 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultTable.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchResultTable.java
@@ -40,6 +40,7 @@ import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
@@ -240,6 +241,10 @@ class FetchResultTable {
private boolean isPruned() {
return update.getNewObjectId().equals(ObjectId.zeroId());
}
+
+ public boolean isRemoteBranch(String branchName) {
+ return update.getRemoteName().equals(branchName);
+ }
}
private final Composite treePanel;
@@ -252,6 +257,8 @@ class FetchResultTable {
private Map<ObjectId, String> abbrevations;
+ private String remoteBranchOfCurrentBranch;
+
@SuppressWarnings("unused")
FetchResultTable(final Composite parent) {
treePanel = new Composite(parent, SWT.NONE);
@@ -304,10 +311,13 @@ class FetchResultTable {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
+ // top level: branches and tags
if (e1 instanceof FetchResultAdapter
&& e2 instanceof FetchResultAdapter) {
FetchResultAdapter f1 = (FetchResultAdapter) e1;
FetchResultAdapter f2 = (FetchResultAdapter) e2;
+
+ // branches come before tags
if (f1.getChildren(f1).length > 0
&& f2.getChildren(f2).length == 0)
return -1;
@@ -315,15 +325,25 @@ class FetchResultTable {
&& f2.getChildren(f2).length > 0)
return 1;
+ // currently checked out branch comes before other branches
+ if (f1.isRemoteBranch(remoteBranchOfCurrentBranch)) {
+ return -1;
+ }
+ if (f2.isRemoteBranch(remoteBranchOfCurrentBranch)) {
+ return 1;
+ }
+
+ // otherwise sort by name
return CommonUtils.STRING_ASCENDING_COMPARATOR
.compare(f1.getLabel(f1), f2.getLabel(f2));
}
- // Leave commits order alone
+ // nested inside of branches: don't change commit order
if (e1 instanceof RepositoryCommit
&& e2 instanceof RepositoryCommit)
return 0;
+ // nested inside commits: sort by path
if (e1 instanceof FileDiff && e2 instanceof FileDiff) {
FileDiff f1 = (FileDiff) e1;
FileDiff f2 = (FileDiff) e2;
@@ -416,6 +436,16 @@ class FetchResultTable {
repo = db;
reader = db.newObjectReader();
abbrevations = new HashMap<>();
+ try {
+ String branch = repo.getBranch();
+ if (branch != null) {
+ remoteBranchOfCurrentBranch = repo.getConfig().getString(
+ ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ ConfigConstants.CONFIG_KEY_MERGE);
+ }
+ } catch (IOException e) {
+ remoteBranchOfCurrentBranch = null;
+ }
treeViewer.setInput(fetchResult);
}

Back to the top