From aa4bbc67b3b18604681b6785e51aa018a7880fb1 Mon Sep 17 00:00:00 2001 From: Robin Stocker Date: Sun, 15 Sep 2013 23:26:35 +0200 Subject: [PATCH] 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 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/lib/BranchTrackingStatus.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java index 7844fd819..1525e5b18 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java @@ -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;