diff options
author | Dave Borowitz <dborowitz@google.com> | 2014-03-25 18:34:54 -0700 |
---|---|---|
committer | Dave Borowitz <dborowitz@google.com> | 2014-03-25 18:39:48 -0700 |
commit | 27473d8e66bda58c51eca6f474885bd893e79f07 (patch) | |
tree | 4f29cb5d676ef00ad87599ed8b6f1a4b18d5c3b0 /org.eclipse.jgit.test/tst/org/eclipse/jgit/api | |
parent | 5c1736a8d8e408c9fa5ae5a1d39eff02772dc7dc (diff) | |
download | jgit-27473d8e66bda58c51eca6f474885bd893e79f07.tar.gz jgit-27473d8e66bda58c51eca6f474885bd893e79f07.zip |
Fix NameRevCommand when repo has no annotated tags
Previously, calling addAnnotatedTags() did not modify any state when
there were no annotated tags in the repository. This caused the code
to assume no addFoo() methods had been called, and fell back to the
default of adding refs/*. Instead, use null to indicate neither
addRefs() nor addAnnotatedTags() was called.
Add a test for this behavior.
Change-Id: I9926e5ac17e1a983cd399798993031c72bd79c2c
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/api')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java index b92a636f58..491595498e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.api; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.util.Map; @@ -109,6 +110,19 @@ public class NameRevCommandTest extends RepositoryTestCase { } @Test + public void annotatedTagsNoResult() throws Exception { + RevCommit c = tr.commit().create(); + tr.update("refs/heads/master", c); + tr.update("refs/tags/tag1", c); + tr.update("refs/tags/tag2", c); + Map<ObjectId, String> result = git.nameRev() + .add(c) + .addAnnotatedTags() + .call(); + assertTrue(result.toString(), result.isEmpty()); + } + + @Test public void simpleAncestor() throws Exception { // 0--1--2 RevCommit c0 = tr.commit().create(); |