From 3813c0d8461221ad482270369791cd79a89d4c1a Mon Sep 17 00:00:00 2001 From: Mathias Kinzler Date: Tue, 18 May 2010 08:53:56 +0200 Subject: [PATCH] BranchSelectionDialog: allow check-out of tags Since tags can now be checked out properly, this offers the checkout for tags on the Branch Selection dialog. Signed-off-by: Mathias Kinzler --- .../ui/internal/dialogs/BranchSelectionDialog.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionDialog.java index 171d2c6c..a9871155 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionDialog.java @@ -124,8 +124,6 @@ public class BranchSelectionDialog extends Dialog { String refName = refNameFromDialog(); - boolean headSelected = Constants.HEAD.equals(refName); - boolean tagSelected = refName != null && refName.startsWith(Constants.R_TAGS); @@ -133,14 +131,15 @@ public class BranchSelectionDialog extends Dialog { && (refName.startsWith(Constants.R_HEADS) || refName .startsWith(Constants.R_REMOTES)); - // TODO add support for checkout of tags - confirmationBtn.setEnabled(branchSelected && !headSelected - && !tagSelected); + // we don't allow reset on tags, but checkout + if (showResetType) + confirmationBtn.setEnabled(branchSelected); + else + confirmationBtn.setEnabled(branchSelected || tagSelected); if (!showResetType) { // we don't support rename on tags - renameButton.setEnabled(branchSelected && !headSelected - && !tagSelected); + renameButton.setEnabled(branchSelected && !tagSelected); // new branch can not be based on a tag newButton.setEnabled(branchSelected && !tagSelected); @@ -215,6 +214,8 @@ public class BranchSelectionDialog extends Dialog { RepositoryTreeNode parentNode; if (refName.startsWith(Constants.R_HEADS)) { parentNode = localBranches; + // TODO fix this: if we are on a local branch or tag, we must do the + // indirection through the commit } else if (refName.startsWith(Constants.R_REMOTES)) { parentNode = remoteBranches; } else if (refName.startsWith(Constants.R_TAGS)) { @@ -297,7 +298,8 @@ public class BranchSelectionDialog extends Dialog { if (sel.size() != 1) return null; RepositoryTreeNode node = (RepositoryTreeNode) sel.getFirstElement(); - if (node.getType() == RepositoryTreeNodeType.REF) { + if (node.getType() == RepositoryTreeNodeType.REF + || node.getType() == RepositoryTreeNodeType.TAG) { return ((Ref) node.getObject()).getName(); } return null; -- 2.11.4.GIT