From 9c84574e8fa53ec432a94cb8a71c14f96d74f74d Mon Sep 17 00:00:00 2001 From: Mathias Kinzler Date: Mon, 14 Feb 2011 15:48:43 +0100 Subject: [PATCH] CreateBranchCommand: Wrong existence check Bug: 337044 Change-Id: I3bc42fea1f552f10d4729999cab6fb4241b70325 Signed-off-by: Mathias Kinzler --- .../src/org/eclipse/jgit/api/CreateBranchCommand.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java index 791145e884..beee9a4ad5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java @@ -124,7 +124,9 @@ public class CreateBranchCommand extends GitCommand { checkCallable(); processOptions(); try { - boolean exists = repo.getRef(name) != null; + Ref refToCheck = repo.getRef(name); + boolean exists = refToCheck != null + && refToCheck.getName().startsWith(Constants.R_HEADS); if (!force && exists) throw new RefAlreadyExistsException(MessageFormat.format( JGitText.get().refAlreadExists, name)); -- 2.39.5