Ver código fonte

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
tags/v3.4.0.201405051725-m7
Robin Rosenberg 10 anos atrás
pai
commit
36f58ef867

+ 5
- 6
org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java Ver arquivo

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

Carregando…
Cancelar
Salvar