diff options
author | florian.signoret <florian.signoret@ibm.com> | 2023-10-16 16:08:14 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-11-18 00:05:35 +0100 |
commit | e4a341db43d5d8a1e6e9c828e3b3e5ddd52b9186 (patch) | |
tree | 0d1dc9118c9e165222cea4cda8cfd122c82cbc87 /org.eclipse.jgit | |
parent | 52af8dbaff46191203b033f05a9fbc1ff0a46886 (diff) | |
download | jgit-e4a341db43d5d8a1e6e9c828e3b3e5ddd52b9186.tar.gz jgit-e4a341db43d5d8a1e6e9c828e3b3e5ddd52b9186.zip |
Fix branch ref exist check
When a tag with the same name as the branch exists, the branch creation
process should work too. We should detect that the branch already
exists, and allow to force create it when the force option is used.
Bug: 582538
Change-Id: I3b350d03be8edcde10e97b2318343240ca896cb0
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java | 4 |
1 files changed, 1 insertions, 3 deletions
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 e1efb86cdc..013e0ff131 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java @@ -88,9 +88,7 @@ public class CreateBranchCommand extends GitCommand<Ref> { checkCallable(); processOptions(); try (RevWalk revWalk = new RevWalk(repo)) { - Ref refToCheck = repo.findRef(name); - boolean exists = refToCheck != null - && refToCheck.getName().startsWith(R_HEADS); + boolean exists = repo.findRef(R_HEADS + name) != null; if (!force && exists) throw new RefAlreadyExistsException(MessageFormat.format( JGitText.get().refAlreadyExists1, name)); |