Browse Source

Fix API ListBranchCommand for listmode 'all'

If remote branches are present they can not be added
to the RefMap from the local branches - the two RefMaps
have a different value of 'prefix' and consequently an
IllegalArgumentException is thrown.
stable-0.11
Roberto Tyley 14 years ago
parent
commit
944fcdae66
  1. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
  2. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java

@ -189,6 +189,12 @@ public class BranchCommandTest extends RepositoryTestCase {
- allBefore); - allBefore);
} }
@Test
public void testListAllBranchesShouldNotDie() throws Exception {
Git git = setUpRepoWithRemote();
git.branchList().setListMode(ListMode.ALL).call();
}
@Test @Test
public void testCreateFromCommit() throws Exception { public void testCreateFromCommit() throws Exception {
Ref branch = git.branchCreate().setName("FromInitial").setStartPoint( Ref branch = git.branchCreate().setName("FromInitial").setStartPoint(

4
org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java

@ -49,6 +49,7 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.HashMap;
import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
@ -100,7 +101,8 @@ public class ListBranchCommand extends GitCommand<List<Ref>> {
} else if (listMode == ListMode.REMOTE) { } else if (listMode == ListMode.REMOTE) {
refList = repo.getRefDatabase().getRefs(Constants.R_REMOTES); refList = repo.getRefDatabase().getRefs(Constants.R_REMOTES);
} else { } else {
refList = repo.getRefDatabase().getRefs(Constants.R_HEADS); refList = new HashMap<String,Ref>(repo.getRefDatabase().getRefs(
Constants.R_HEADS));
refList.putAll(repo.getRefDatabase().getRefs( refList.putAll(repo.getRefDatabase().getRefs(
Constants.R_REMOTES)); Constants.R_REMOTES));
} }

Loading…
Cancel
Save