From 891a2d75e7820e8f18e963e44a4b93ecad49c421 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Thu, 10 Jan 2013 10:53:54 -0800 Subject: [PATCH] Peel tags during resolve of foo^ Once we start talking about parents of tags, we are in the commit graph, so treat all objects from this point as commits. This fixes spurious IncorrectObjectTypeExceptions on resolving expressions like tag^^. Change-Id: I29ece1fdb49c9c5b9ca415efcd1876bc72e97120 --- .../tst/org/eclipse/jgit/lib/RepositoryResolveTest.java | 2 ++ org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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 91364ce98..12b9dc94c 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 @@ -178,9 +178,11 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/B10th^0").name()); assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/B10th~0").name()); assertEquals("0966a434eb1a025db6b71485ab63a3bfbea520b6",db.resolve("refs/tags/B10th^").name()); + assertEquals("2c349335b7f797072cf729c4f3bb0914ecb6dec9",db.resolve("refs/tags/B10th^^").name()); assertEquals("0966a434eb1a025db6b71485ab63a3bfbea520b6",db.resolve("refs/tags/B10th^1").name()); assertEquals("0966a434eb1a025db6b71485ab63a3bfbea520b6",db.resolve("refs/tags/B10th~1").name()); assertEquals("2c349335b7f797072cf729c4f3bb0914ecb6dec9",db.resolve("refs/tags/B10th~2").name()); + assertEquals("2c349335b7f797072cf729c4f3bb0914ecb6dec9",db.resolve("refs/tags/B10th^~1").name()); } @Test diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index 75053796b..b36f7e87b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -509,7 +509,7 @@ public abstract class Repository { done = k; break; default: - rev = rw.parseAny(rev); + rev = rw.peel(rev); if (rev instanceof RevCommit) { RevCommit commit = ((RevCommit) rev); if (commit.getParentCount() == 0)