IDEA-61839 Git Log: Filter by branch: remotes/origin/HEAD -> origin/master doesn't work

This commit is contained in:
irengrig
2011-02-07 19:19:34 +03:00
parent 5b098b7afd
commit b265d1c49b
+23 -3
View File
@@ -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;
}
}