From 27b8a0d7c8a07670e04fff31904ddcf4434c128a Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 26 Jul 2012 18:18:24 +0400 Subject: [PATCH] GitCompareWithBranchAction: fix the title of the current revision Display current branch name (or short hash), not the full hash. --- .../actions/GitCompareWithBranchAction.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/git4idea/src/git4idea/actions/GitCompareWithBranchAction.java b/plugins/git4idea/src/git4idea/actions/GitCompareWithBranchAction.java index 925cd756b38d..9a6cb5ee090f 100644 --- a/plugins/git4idea/src/git4idea/actions/GitCompareWithBranchAction.java +++ b/plugins/git4idea/src/git4idea/actions/GitCompareWithBranchAction.java @@ -66,13 +66,20 @@ public class GitCompareWithBranchAction extends DumbAwareAction { final VirtualFile file = getAffectedFile(event); GitRepositoryManager manager = GitUtil.getRepositoryManager(project); - if (manager == null) { - return; - } GitRepository repository = manager.getRepositoryForFile(file); assert repository != null; - final String head = repository.getCurrentRevision(); + GitBranch currentBranch = repository.getCurrentBranch(); + final String head; + if (currentBranch == null) { + String currentRevision = repository.getCurrentRevision(); + LOG.assertTrue(currentRevision != null, + "Current revision is null for " + repository + ". Compare with branch shouldn't be available for fresh repository"); + head = GitUtil.getShortHash(currentRevision); + } + else { + head = currentBranch.getName(); + } final List branchNames = getBranchNamesExceptCurrent(repository); // prepare and invoke popup @@ -132,11 +139,6 @@ public class GitCompareWithBranchAction extends DumbAwareAction { } GitRepositoryManager manager = GitUtil.getRepositoryManager(project); - if (manager == null) { - presentation.setEnabled(false); - presentation.setVisible(true); - return; - } GitRepository repository = manager.getRepositoryForFile(vFiles[0]); if (repository == null || repository.isFresh() || noBranchesToCompare(repository)) {