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
This commit is contained in:
parent
6605255d99
commit
36f58ef867
|
@ -246,12 +246,11 @@ else if (upstreamMode == SetupUpstreamMode.NOTRACK)
|
||||||
|
|
||||||
if (doConfigure) {
|
if (doConfigure) {
|
||||||
StoredConfig config = repo.getConfig();
|
StoredConfig config = repo.getConfig();
|
||||||
String[] tokens = baseBranch.split("/", 4); //$NON-NLS-1$
|
|
||||||
boolean isRemote = tokens[1].equals("remotes"); //$NON-NLS-1$
|
String remoteName = repo.getRemoteName(baseBranch);
|
||||||
if (isRemote) {
|
if (remoteName != null) {
|
||||||
// refs/remotes/<remote name>/<branch>
|
String branchName = repo
|
||||||
String remoteName = tokens[2];
|
.shortenRemoteBranchName(baseBranch);
|
||||||
String branchName = tokens[3];
|
|
||||||
config
|
config
|
||||||
.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
|
.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
|
||||||
name, ConfigConstants.CONFIG_KEY_REMOTE,
|
name, ConfigConstants.CONFIG_KEY_REMOTE,
|
||||||
|
|
Loading…
Reference in New Issue