Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2013-04-21 23:03:32 +0000
committerMatthias Sohn2013-04-23 08:43:49 +0000
commit5276571a7eca1734da524ece5166ecdb201db257 (patch)
tree441cf20923cb4a59a7a8f22fd5ff85ea1f6b5364 /org.eclipse.egit.ui
parent7569711a8026abf3e4b64f3fe613154c274a92cf (diff)
downloadegit-5276571a7eca1734da524ece5166ecdb201db257.tar.gz
egit-5276571a7eca1734da524ece5166ecdb201db257.tar.xz
egit-5276571a7eca1734da524ece5166ecdb201db257.zip
History View: Allow checkout of remote tracking branch
Couldn't checkout remote tracking branch if it points to same commit as the currently checked out branch. Bug: 385002 Change-Id: If07412a40cb28303af96c559fa1951efb81ec322 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CheckoutCommitHandler.java5
2 files changed, 11 insertions, 5 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
index 8f2bde964d..061742bb9a 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
@@ -14,6 +14,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -204,16 +205,18 @@ abstract class AbstractHistoryCommandHandler extends AbstractHandler {
*
* @param commit
* @param repo
- * @param refPrefix
+ * @param refPrefixes
* e.g. "refs/heads/" or ""
* @return a list of RefNodes
*/
- protected List<RefNode> getRefNodes(RevCommit commit, Repository repo, String refPrefix) {
+ protected List<RefNode> getRefNodes(RevCommit commit, Repository repo,
+ String... refPrefixes) {
List<Ref> availableBranches = new ArrayList<Ref>();
List<RefNode> nodes = new ArrayList<RefNode>();
try {
- Map<String, Ref> branches = repo.getRefDatabase().getRefs(
- refPrefix);
+ Map<String, Ref> branches = new HashMap<String, Ref>();
+ for (String refPrefix : refPrefixes)
+ branches.putAll(repo.getRefDatabase().getRefs(refPrefix));
for (Ref branch : branches.values()) {
if (branch.getLeaf().getObjectId().equals(commit.getId()))
availableBranches.add(branch);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CheckoutCommitHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CheckoutCommitHandler.java
index 18cfc813fe..1813e040fb 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CheckoutCommitHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CheckoutCommitHandler.java
@@ -8,6 +8,7 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.history.command;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.commands.ExecutionEvent;
@@ -35,7 +36,9 @@ public class CheckoutCommitHandler extends AbstractHistoryCommandHandler {
final BranchOperationUI op;
- List<RefNode> nodes = getRefNodes(commit, repo, Constants.R_HEADS);
+ List<RefNode> nodes = getRefNodes(commit, repo, Constants.R_HEADS,
+ Constants.R_REMOTES);
+ Collections.sort(nodes);
if (nodes.isEmpty())
op = BranchOperationUI.checkout(repo, commit.name());

Back to the top