Browse Source

Use full branch name when getting ref in BranchTrackingStatus

In case there is both a tag and branch called "foo", the tag is returned
if calling getRef with the short name. By using refs/heads/foo, the
branch is returned.

Bug: 417158
Change-Id: I86b4f83955586bb24774fd621f5012499cf67909
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v3.1.0.201309270735-rc1
Robin Stocker 10 years ago
parent
commit
aa4bbc67b3

+ 4
- 2
org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java View File

@@ -70,8 +70,10 @@ public class BranchTrackingStatus {
public static BranchTrackingStatus of(Repository repository, String branchName)
throws IOException {

String shortBranchName = Repository.shortenRefName(branchName);
String fullBranchName = Constants.R_HEADS + shortBranchName;
BranchConfig branchConfig = new BranchConfig(repository.getConfig(),
branchName);
shortBranchName);

String trackingBranch = branchConfig.getTrackingBranch();
if (trackingBranch == null)
@@ -81,7 +83,7 @@ public class BranchTrackingStatus {
if (tracking == null)
return null;

Ref local = repository.getRef(branchName);
Ref local = repository.getRef(fullBranchName);
if (local == null)
return null;


Loading…
Cancel
Save