diff options
author | Roberto Tyley | 2011-01-12 09:34:10 -0500 |
---|---|---|
committer | Roberto Tyley | 2011-01-12 09:34:10 -0500 |
commit | 944fcdae66bb4de712e2eadec73d8008d3a9bace (patch) | |
tree | b92a65c2e7d53aa90e849bac0879374fd8f113dc | |
parent | be38185a033021da707f934caf96b68070050bd5 (diff) | |
download | jgit-944fcdae66bb4de712e2eadec73d8008d3a9bace.zip jgit-944fcdae66bb4de712e2eadec73d8008d3a9bace.tar.gz jgit-944fcdae66bb4de712e2eadec73d8008d3a9bace.tar.xz |
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.
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java | 6 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java index eb1b72e..7464a5e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java @@ -190,6 +190,12 @@ public class BranchCommandTest extends RepositoryTestCase { } @Test + public void testListAllBranchesShouldNotDie() throws Exception { + Git git = setUpRepoWithRemote(); + git.branchList().setListMode(ListMode.ALL).call(); + } + + @Test public void testCreateFromCommit() throws Exception { Ref branch = git.branchCreate().setName("FromInitial").setStartPoint( initialCommit).call(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java index 8329fca..846c538 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java +++ b/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.List; import java.util.Map; +import java.util.HashMap; import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.lib.Constants; @@ -100,7 +101,8 @@ public class ListBranchCommand extends GitCommand<List<Ref>> { } else if (listMode == ListMode.REMOTE) { refList = repo.getRefDatabase().getRefs(Constants.R_REMOTES); } else { - refList = repo.getRefDatabase().getRefs(Constants.R_HEADS); + refList = new HashMap<String,Ref>(repo.getRefDatabase().getRefs( + Constants.R_HEADS)); refList.putAll(repo.getRefDatabase().getRefs( Constants.R_REMOTES)); } |