Browse Source

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
stable-3.4
Robin Rosenberg 11 years ago
parent
commit
36f58ef867
  1. 11
      org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java

11
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,

Loading…
Cancel
Save