From b265d1c49bf3f6308d794c21f3ef60806e95c24b Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 7 Feb 2011 19:04:43 +0300 Subject: [PATCH] IDEA-61839 Git Log: Filter by branch: remotes/origin/HEAD -> origin/master doesn't work --- plugins/git4idea/src/git4idea/GitBranch.java | 26 +++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/git4idea/src/git4idea/GitBranch.java b/plugins/git4idea/src/git4idea/GitBranch.java index 760fde91957e..aba9ab2189ff 100644 --- a/plugins/git4idea/src/git4idea/GitBranch.java +++ b/plugins/git4idea/src/git4idea/GitBranch.java @@ -40,7 +40,7 @@ public class GitBranch extends GitReference { @NonNls public static final String REFS_REMOTES_PREFIX = "refs/remotes/"; // Prefix for remote branches ({@value}) private final boolean myRemote; - private final boolean myActive; + private boolean myActive; public GitBranch(@NotNull String name, boolean active, boolean remote) { super(name); @@ -179,6 +179,7 @@ public class GitBranch extends GitReference { // origin/HEAD -> origin/master final String[] split = output.split("\n"); GitBranch currentBranch = null; + String activeRemoteName = null; for (String b : split) { boolean current = b.charAt(0) == '*'; b = b.substring(2).trim(); @@ -191,8 +192,15 @@ public class GitBranch extends GitReference { remotePrefix = REFS_REMOTES_PREFIX; } boolean isRemote = remotePrefix != null || remoteOnly; - if (isRemote && !remoteOnly) { - b = b.substring(remotePrefix.length()); + if (isRemote) { + if (! remoteOnly) { + b = b.substring(remotePrefix.length()); + } + final int idx = b.indexOf("HEAD ->"); + if (idx > 0) { + activeRemoteName = b.substring(idx + "HEAD ->".length() + remotePrefix.length()); + continue; + } } final GitBranch branch = new GitBranch(b, current, isRemote); if (current) { @@ -202,6 +210,14 @@ public class GitBranch extends GitReference { branches.add(branch); } } + if (activeRemoteName != null) { + for (GitBranch branch : branches) { + if (activeRemoteName.equals(branch.getName())) { + branch.setActive(true); + break; + } + } + } return currentBranch; } @@ -294,4 +310,8 @@ public class GitBranch extends GitReference { return GitRevisionNumber.resolve(project, root, output); } } + + public void setActive(boolean active) { + myActive = active; + } }