diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2014-04-26 13:05:53 +0200 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2014-04-27 10:38:33 +0200 |
commit | 36f58ef867fc180aaca20dfa58a1b14f6b79e59a (patch) | |
tree | 59b272f8a42e760ad9661a5a02ecf6984a70f031 /org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java | |
parent | 6605255d9906c5277d215396ebcc395484b9f10c (diff) | |
download | jgit-36f58ef867fc180aaca20dfa58a1b14f6b79e59a.tar.gz jgit-36f58ef867fc180aaca20dfa58a1b14f6b79e59a.zip |
Fix ArrayIndexOutOfBoundsException in CreateBranchCommand
If remote name contains / or there was a branch directly under the
refs/remotes namespace (wrong) the computation of remote name and
suggested local branch name would fail. Fix this by looking at the
configured remotes. A ref under refs/remotes that does not match a
remote configuration is not considered a remote tracking branch anymore.
This patch does not fix all similar errors in EGit/JGit.
Bug: 411002
Bug: 400414
Change-Id: I2515a6ed05f9104c387ce4e43b24dae942ae2473
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java | 11 |
1 files changed, 5 insertions, 6 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 aa1484c0f9..92e8b466b0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java @@ -246,12 +246,11 @@ public class CreateBranchCommand extends GitCommand<Ref> { if (doConfigure) { StoredConfig config = repo.getConfig(); - String[] tokens = baseBranch.split("/", 4); //$NON-NLS-1$ - boolean isRemote = tokens[1].equals("remotes"); //$NON-NLS-1$ - if (isRemote) { - // refs/remotes/<remote name>/<branch> - String remoteName = tokens[2]; - String branchName = tokens[3]; + + String remoteName = repo.getRemoteName(baseBranch); + if (remoteName != null) { + String branchName = repo + .shortenRemoteBranchName(baseBranch); config .setString(ConfigConstants.CONFIG_BRANCH_SECTION, name, ConfigConstants.CONFIG_KEY_REMOTE, |