diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-03-03 16:17:29 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-03-03 16:17:29 -0800 |
commit | b21c82fdb0edc79735251550cacf37491adb8a61 (patch) | |
tree | 131e12f7e6f3815c28ed7461e80158a488d8d5a8 /org.eclipse.jgit.test/tst | |
parent | 3ee3588b86637f97f98f2562171762822cfc2ce6 (diff) | |
download | jgit-b21c82fdb0edc79735251550cacf37491adb8a61.tar.gz jgit-b21c82fdb0edc79735251550cacf37491adb8a61.zip |
resolve(): Fix wrong parsing of branch "foo-gbed2-dev"
When parsing a string such as "foo-gbed2" resolve() was assuming the
suffix was from git describe output. This lead to JGit trying to find
the completion for the object abbreviation "bed2", rather than using
the current value of the reference. If there was only one such object
in the repository, JGit might actually use the wrong value here, as
resolve() would return the completion of the abbreviation "bed2"
rather than the current value of the reference "refs/heads/foo-gbed2".
Move the parsing of git describe abbreviations out of the operator
portion of the resolve() method and into the simple portion that is
supposed to handle only object ids or reference names, and only do the
describe parsing after all other approaches have already failed to
provide a resolution.
Add new unit tests to verify the behavior is as expected by users.
Bug: 338839
Change-Id: I52054d7b89628700c730f9a4bd7743b16b9042a9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java index 5ad913c569..d55856acea 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java @@ -48,6 +48,7 @@ package org.eclipse.jgit.lib; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import java.io.IOException; @@ -182,6 +183,24 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { } @Test + public void testParseNonGitDescribe() throws IOException { + ObjectId id = id("49322bb17d3acc9146f98c97d078513228bbf3c0"); + RefUpdate ru = db.updateRef("refs/heads/foo-g032c"); + ru.setNewObjectId(id); + assertSame(RefUpdate.Result.NEW, ru.update()); + + assertEquals(id, db.resolve("refs/heads/foo-g032c")); + assertEquals(id, db.resolve("foo-g032c")); + + ru = db.updateRef("refs/heads/foo-g032c-dev"); + ru.setNewObjectId(id); + assertSame(RefUpdate.Result.NEW, ru.update()); + + assertEquals(id, db.resolve("refs/heads/foo-g032c-dev")); + assertEquals(id, db.resolve("foo-g032c-dev")); + } + + @Test public void testParseLookupPath() throws IOException { ObjectId b2_txt = id("10da5895682013006950e7da534b705252b03be6"); ObjectId b3_b2_txt = id("e6bfff5c1d0f0ecd501552b43a1e13d8008abc31"); |