* [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} @ 2008-09-11 21:39 Jonas Fonseca 2008-09-11 22:47 ` Robin Rosenberg 0 siblings, 1 reply; 10+ messages in thread From: Jonas Fonseca @ 2008-09-11 21:39 UTC (permalink / raw) To: Robin Rosenberg, Shawn O. Pearce; +Cc: git Repository.resolve("tag^0") failed with "not a commit". Fix it and add a test case for it. Signed-off-by: Jonas Fonseca <fonseca@diku.dk> --- .../org/spearce/jgit/lib/T0008_testparserev.java | 9 ++++++++- .../src/org/spearce/jgit/lib/Repository.java | 5 +++++ 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java index 8883b8b..3457574 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java @@ -109,10 +109,17 @@ public void testDerefTag() throws IOException { assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("spearce-gpg-pub^{blob}").name()); } + public void testDerefTagIssue23() throws IOException { + assertEquals("17768080a2318cd89bba4c8b87834401e2095703",db.resolve("refs/tags/B").name()); + assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/B^{commit}").name()); + // The special tag^0 == tag^{commit} rule + assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/B^0").name()); + } + public void testDerefBlob() throws IOException { assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("fd608fbe625a2b456d9f15c2b1dc41f252057dd7^{}").name()); assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("fd608fbe625a2b456d9f15c2b1dc41f252057dd7^{blob}").name()); } - + // TODO: ^{tree} for a tag pointing to a tag } diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java index b27c23d..260a39d 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java @@ -562,6 +562,11 @@ public ObjectId resolve(final String revstr) throws IOException { case '9': int j; ref = mapObject(refId, null); + if (ref instanceof Tag && rev[i + 1] == '0') { + Tag tag = (Tag)ref; + refId = tag.getObjId(); + ref = mapObject(refId, null); + } if (!(ref instanceof Commit)) throw new IncorrectObjectTypeException(refId, Constants.TYPE_COMMIT); for (j=i+1; j<rev.length; ++j) { -- 1.6.0.336.ga07ba -- Jonas Fonseca ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} 2008-09-11 21:39 [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} Jonas Fonseca @ 2008-09-11 22:47 ` Robin Rosenberg 2008-09-12 0:00 ` Jonas Fonseca 0 siblings, 1 reply; 10+ messages in thread From: Robin Rosenberg @ 2008-09-11 22:47 UTC (permalink / raw) To: Jonas Fonseca; +Cc: Shawn O. Pearce, git torsdagen den 11 september 2008 23.39.27 skrev Jonas Fonseca: > Repository.resolve("tag^0") failed with "not a commit". Fix it and add a > test case for it. It seems this case is not *that* special. It is tag^N == tag^{commit}^N Same for tag~N == tag^{commit}~N- My fault, i guess, but it would be nice of you fixed it while you are at it. Second, the testcase in the second patch fails on my machine. testDerefTaggedTagTree(org.spearce.jgit.lib.T0008_testparserev) junit.framework.ComparisonFailure: expected:<[269e1253bad5c247c6bde37aa48ae1e03138206c]> but was:<[be83157b4ffe650d728ba4f98ad47b623b0d0c20]> at junit.framework.Assert.assertEquals(Assert.java:81) at junit.framework.Assert.assertEquals(Assert.java:87) at org.spearce.jgit.lib.T0008_testparserev.testDerefTaggedTagTree(T0008_testparserev.java:123) -- robin ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} 2008-09-11 22:47 ` Robin Rosenberg @ 2008-09-12 0:00 ` Jonas Fonseca 2008-09-12 1:51 ` Imran M Yousuf 2008-09-12 6:47 ` [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} Robin Rosenberg 0 siblings, 2 replies; 10+ messages in thread From: Jonas Fonseca @ 2008-09-12 0:00 UTC (permalink / raw) To: Robin Rosenberg; +Cc: Shawn O. Pearce, git, Imran M Yousuf Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote Fri, Sep 12, 2008: > torsdagen den 11 september 2008 23.39.27 skrev Jonas Fonseca: > > Repository.resolve("tag^0") failed with "not a commit". Fix it and add a > > test case for it. > > It seems this case is not *that* special. It is tag^N == tag^{commit}^N > Same for tag~N == tag^{commit}~N- git-rev-parse(1) says: · A suffix ^ to a revision parameter means the first parent of that commit object. ^<n> means the <n>th parent (i.e. rev^ is equivalent to rev^1). As a special rule, rev^0 means the commit itself and is used when rev is the object name of a tag object that refers to a commit object. but does take tag^1, however not tag^2. It looks like tag~N is broken in JGit ("not a commit") so should also be fixed if we want to be compatible with git-rev-parse. BTW, I just noticed that ^{} is not handled correctly either for tags. · A suffix ^ followed by an empty brace pair (e.g. v0.99.8^{}) means the object could be a tag, and dereference the tag recursively until a non-tag object is found. Only one derefence is performed. > My fault, i guess, but it would be nice of you fixed it while you are at it. I will try to make fixes for the above cases tomorrow. > Second, the testcase in the second patch fails on my machine. > > testDerefTaggedTagTree(org.spearce.jgit.lib.T0008_testparserev) > junit.framework.ComparisonFailure: expected:<[269e1253bad5c247c6bde37aa48ae1e03138206c]> but was:<[be83157b4ffe650d728ba4f98ad47b623b0d0c20]> > at junit.framework.Assert.assertEquals(Assert.java:81) > at junit.framework.Assert.assertEquals(Assert.java:87) > at org.spearce.jgit.lib.T0008_testparserev.testDerefTaggedTagTree(T0008_testparserev.java:123) I reran all the test before formatting the patch, but after doing some last minut changes. When I run all the tests using maven (inside NetBeans or from the command line) it tells me: Tests run: 428, Failures: 0, Errors: 0, Skipped: 0 From the output it looks like the tests in the files named T000* are never run. However, where the breakage is (could be my setup) I don't know. Imran? Anyway, for now I will just run the single test specifically. Perhaps I should just put this into the same patch. Anyway, the following should fix it. diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java index 2a1a4ad..1fc73b4 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java @@ -117,7 +117,7 @@ public void testDerefTagIssue23() throws IOException { } public void testDerefTaggedTagTree() throws IOException { - assertEquals("269e1253bad5c247c6bde37aa48ae1e03138206c",db.resolve("refs/tags/C").name()); + assertEquals("be83157b4ffe650d728ba4f98ad47b623b0d0c20",db.resolve("refs/tags/C").name()); assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/C^{commit}").name()); assertEquals("856ec208ae6cadac25a6d74f19b12bb27a24fe24",db.resolve("refs/tags/C^{tree}").name()); } -- Jonas Fonseca ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} 2008-09-12 0:00 ` Jonas Fonseca @ 2008-09-12 1:51 ` Imran M Yousuf 2008-09-12 8:40 ` [JGIT PATCH] Configure the maven surefire plugin to specifically include all tests Jonas Fonseca 2008-09-12 6:47 ` [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} Robin Rosenberg 1 sibling, 1 reply; 10+ messages in thread From: Imran M Yousuf @ 2008-09-12 1:51 UTC (permalink / raw) To: Jonas Fonseca; +Cc: Robin Rosenberg, Shawn O. Pearce, git, Imran M Yousuf On Fri, Sep 12, 2008 at 6:00 AM, Jonas Fonseca <fonseca@diku.dk> wrote: >> Second, the testcase in the second patch fails on my machine. >> >> testDerefTaggedTagTree(org.spearce.jgit.lib.T0008_testparserev) >> junit.framework.ComparisonFailure: expected:<[269e1253bad5c247c6bde37aa48ae1e03138206c]> but was:<[be83157b4ffe650d728ba4f98ad47b623b0d0c20]> >> at junit.framework.Assert.assertEquals(Assert.java:81) >> at junit.framework.Assert.assertEquals(Assert.java:87) >> at org.spearce.jgit.lib.T0008_testparserev.testDerefTaggedTagTree(T0008_testparserev.java:123) > > I reran all the test before formatting the patch, but after doing some > last minut changes. When I run all the tests using maven (inside > NetBeans or from the command line) it tells me: > > Tests run: 428, Failures: 0, Errors: 0, Skipped: 0 > > From the output it looks like the tests in the files named T000* are > never run. However, where the breakage is (could be my setup) I don't > know. Imran? > Hmm, I will have to check it. Will come back with some feedback after checking. Usually if a class is a TestCase then it should have run. > Anyway, for now I will just run the single test specifically. Perhaps I > should just put this into the same patch. Anyway, the following should > fix it. > > diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java > index 2a1a4ad..1fc73b4 100644 > --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java > +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java > @@ -117,7 +117,7 @@ public void testDerefTagIssue23() throws IOException { > } > > public void testDerefTaggedTagTree() throws IOException { > - assertEquals("269e1253bad5c247c6bde37aa48ae1e03138206c",db.resolve("refs/tags/C").name()); > + assertEquals("be83157b4ffe650d728ba4f98ad47b623b0d0c20",db.resolve("refs/tags/C").name()); > assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/C^{commit}").name()); > assertEquals("856ec208ae6cadac25a6d74f19b12bb27a24fe24",db.resolve("refs/tags/C^{tree}").name()); > } > > -- > Jonas Fonseca > -- Imran M Yousuf Entrepreneur & Software Engineer Smart IT Engineering Dhaka, Bangladesh Email: imran@smartitengineering.com Blog: http://imyousuf-tech.blogs.smartitengineering.com/ Mobile: +880-1711402557 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [JGIT PATCH] Configure the maven surefire plugin to specifically include all tests 2008-09-12 1:51 ` Imran M Yousuf @ 2008-09-12 8:40 ` Jonas Fonseca 2008-09-12 14:47 ` Shawn O. Pearce 0 siblings, 1 reply; 10+ messages in thread From: Jonas Fonseca @ 2008-09-12 8:40 UTC (permalink / raw) To: Imran M Yousuf; +Cc: Robin Rosenberg, Shawn O. Pearce, git, Imran M Yousuf By default, the test cases named T000* were not included. With this patch maven reports that 508 tests have been run. Signed-off-by: Jonas Fonseca <fonseca@diku.dk> --- jgit-maven/jgit/pom.xml | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) Imran M Yousuf <imran@smartitengineering.com> wrote Fri, Sep 12, 2008: > On Fri, Sep 12, 2008 at 6:00 AM, Jonas Fonseca <fonseca@diku.dk> wrote: > > When I run all the tests using maven (inside > > NetBeans or from the command line) it tells me: > > > > Tests run: 428, Failures: 0, Errors: 0, Skipped: 0 > > > > From the output it looks like the tests in the files named T000* are > > never run. However, where the breakage is (could be my setup) I don't > > know. Imran? > > > > Hmm, I will have to check it. Will come back with some feedback after > checking. Usually if a class is a TestCase then it should have run. I started looking for possible bug reports at jira.codehaus.org and found an issue for extendeding the default path patterns used for including and excluding tests. Maybe something like this patch is clean enough, at least it increases "my coverage" to 508 tests. diff --git a/jgit-maven/jgit/pom.xml b/jgit-maven/jgit/pom.xml index a64f53c..a123470 100644 --- a/jgit-maven/jgit/pom.xml +++ b/jgit-maven/jgit/pom.xml @@ -158,6 +158,17 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <encoding>UTF-8</encoding> </configuration> </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.4.2</version> + <configuration> + <includes> + <include>**/*Test.java</include> + <include>**/*TestCase.java</include> + <include>**/T000*.java</include> + </includes> + </configuration> + </plugin> </plugins> </build> <dependencies> -- 1.6.0.1.451.gc8d31 -- Jonas Fonseca ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [JGIT PATCH] Configure the maven surefire plugin to specifically include all tests 2008-09-12 8:40 ` [JGIT PATCH] Configure the maven surefire plugin to specifically include all tests Jonas Fonseca @ 2008-09-12 14:47 ` Shawn O. Pearce 0 siblings, 0 replies; 10+ messages in thread From: Shawn O. Pearce @ 2008-09-12 14:47 UTC (permalink / raw) To: Jonas Fonseca; +Cc: Imran M Yousuf, Robin Rosenberg, git, Imran M Yousuf Jonas Fonseca <fonseca@diku.dk> wrote: > By default, the test cases named T000* were not included. With this > patch maven reports that 508 tests have been run. Thanks. 508 is the correct current number of tests. > + <plugin> > + <artifactId>maven-surefire-plugin</artifactId> > + <version>2.4.2</version> > + <configuration> > + <includes> > + <include>**/*Test.java</include> > + <include>**/*TestCase.java</include> > + <include>**/T000*.java</include> > + </includes> > + </configuration> > + </plugin> -- Shawn. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} 2008-09-12 0:00 ` Jonas Fonseca 2008-09-12 1:51 ` Imran M Yousuf @ 2008-09-12 6:47 ` Robin Rosenberg 2008-09-12 10:57 ` [JGIT PATCH 1/3] Fix IncorrectObjectTypeException thrown for incorrect ^{blob} Jonas Fonseca ` (2 more replies) 1 sibling, 3 replies; 10+ messages in thread From: Robin Rosenberg @ 2008-09-12 6:47 UTC (permalink / raw) To: Jonas Fonseca; +Cc: Shawn O. Pearce, git, Imran M Yousuf fredagen den 12 september 2008 02.00.07 skrev Jonas Fonseca: > Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote Fri, Sep 12, 2008: > > torsdagen den 11 september 2008 23.39.27 skrev Jonas Fonseca: > > > Repository.resolve("tag^0") failed with "not a commit". Fix it and add a > > > test case for it. > > > > It seems this case is not *that* special. It is tag^N == tag^{commit}^N > > Same for tag~N == tag^{commit}~N- > > git-rev-parse(1) says: > > · A suffix ^ to a revision parameter means the first parent of that > commit object. ^<n> means the <n>th parent (i.e. rev^ is > equivalent to rev^1). As a special rule, rev^0 means the commit > itself and is used when rev is the object name of a tag object that > refers to a commit object. > > but does take tag^1, however not tag^2. It looks like tag~N is broken in tag^2 means you have a merge commit. I think rev^0 is mentioned here to mean that it is actually defined (and how). > JGit ("not a commit") so should also be fixed if we want to be > compatible with git-rev-parse. > > BTW, I just noticed that ^{} is not handled correctly either for tags. > · A suffix ^ followed by an empty brace pair (e.g. v0.99.8^{}) means > the object could be a tag, and dereference the tag recursively > until a non-tag object is found. > > Only one derefence is performed. Good catch! > > My fault, i guess, but it would be nice of you fixed it while you are at it. > > I will try to make fixes for the above cases tomorrow. > > > Second, the testcase in the second patch fails on my machine. > > > > testDerefTaggedTagTree(org.spearce.jgit.lib.T0008_testparserev) > > junit.framework.ComparisonFailure: expected:<[269e1253bad5c247c6bde37aa48ae1e03138206c]> but was:<[be83157b4ffe650d728ba4f98ad47b623b0d0c20]> > > at junit.framework.Assert.assertEquals(Assert.java:81) > > at junit.framework.Assert.assertEquals(Assert.java:87) > > at org.spearce.jgit.lib.T0008_testparserev.testDerefTaggedTagTree(T0008_testparserev.java:123) > > I reran all the test before formatting the patch, but after doing some > last minut changes. When I run all the tests using maven (inside > NetBeans or from the command line) it tells me: > > Tests run: 428, Failures: 0, Errors: 0, Skipped: 0 > > From the output it looks like the tests in the files named T000* are > never run. However, where the breakage is (could be my setup) I don't > know. Imran? > > Anyway, for now I will just run the single test specifically. Perhaps I > should just put this into the same patch. Anyway, the following should > fix it. Yes, please resubmit after updating the rev-parsing code. > diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java > index 2a1a4ad..1fc73b4 100644 > --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java > +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java > @@ -117,7 +117,7 @@ public void testDerefTagIssue23() throws IOException { > } > > public void testDerefTaggedTagTree() throws IOException { > - assertEquals("269e1253bad5c247c6bde37aa48ae1e03138206c",db.resolve("refs/tags/C").name()); > + assertEquals("be83157b4ffe650d728ba4f98ad47b623b0d0c20",db.resolve("refs/tags/C").name()); > assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/C^{commit}").name()); > assertEquals("856ec208ae6cadac25a6d74f19b12bb27a24fe24",db.resolve("refs/tags/C^{tree}").name()); > } > My guess is you added to original test tag C manually so it got an "non-deterministic" time stamp. -- robin ^ permalink raw reply [flat|nested] 10+ messages in thread
* [JGIT PATCH 1/3] Fix IncorrectObjectTypeException thrown for incorrect ^{blob} 2008-09-12 6:47 ` [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} Robin Rosenberg @ 2008-09-12 10:57 ` Jonas Fonseca 2008-09-12 10:57 ` [JGIT PATCH 2/3] Fix off by one distance during resolving of commit~N Jonas Fonseca 2008-09-12 10:57 ` [JGIT PATCH 3/3] Tests and fixes for dereferencing tags in Repository.resolve() Jonas Fonseca 2 siblings, 0 replies; 10+ messages in thread From: Jonas Fonseca @ 2008-09-12 10:57 UTC (permalink / raw) To: Robin Rosenberg; +Cc: Shawn O. Pearce, git Signed-off-by: Jonas Fonseca <fonseca@diku.dk> --- .../src/org/spearce/jgit/lib/Repository.java | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java index b27c23d..730a267 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java @@ -628,7 +628,7 @@ else if (item.equals("blob")) { ref = mapObject(refId, null); } if (!(ref instanceof byte[])) - throw new IncorrectObjectTypeException(refId, Constants.TYPE_COMMIT); + throw new IncorrectObjectTypeException(refId, Constants.TYPE_BLOB); } else if (item.equals("")) { ref = mapObject(refId, null); -- 1.6.0.1.451.gc8d31 -- Jonas Fonseca ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [JGIT PATCH 2/3] Fix off by one distance during resolving of commit~N 2008-09-12 6:47 ` [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} Robin Rosenberg 2008-09-12 10:57 ` [JGIT PATCH 1/3] Fix IncorrectObjectTypeException thrown for incorrect ^{blob} Jonas Fonseca @ 2008-09-12 10:57 ` Jonas Fonseca 2008-09-12 10:57 ` [JGIT PATCH 3/3] Tests and fixes for dereferencing tags in Repository.resolve() Jonas Fonseca 2 siblings, 0 replies; 10+ messages in thread From: Jonas Fonseca @ 2008-09-12 10:57 UTC (permalink / raw) To: Robin Rosenberg; +Cc: Shawn O. Pearce, git To be compatible with git-rev-parse, commit~0 should resolve to commit, commit~1 to commit^, etc. Signed-off-by: Jonas Fonseca <fonseca@diku.dk> --- .../org/spearce/jgit/lib/T0008_testparserev.java | 9 +++++---- .../src/org/spearce/jgit/lib/Repository.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java index 8883b8b..506f51f 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java @@ -82,10 +82,11 @@ public void testRef_refname() throws IOException { } public void testDistance() throws IOException { - assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~0").name()); - assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~1").name()); - assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~2").name()); - assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~02").name()); + assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~0").name()); + assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~1").name()); + assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~2").name()); + assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~3").name()); + assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~03").name()); } public void testTree() throws IOException { diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java index 730a267..894fe3b 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java @@ -688,7 +688,7 @@ else if (item.equals("")) { throw new RevisionSyntaxException( "Invalid ancestry length", revstr); } - while (dist >= 0) { + while (dist > 0) { final ObjectId[] parents = ((Commit) ref).getParentIds(); if (parents.length == 0) { refId = null; -- 1.6.0.1.451.gc8d31 -- Jonas Fonseca ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [JGIT PATCH 3/3] Tests and fixes for dereferencing tags in Repository.resolve() 2008-09-12 6:47 ` [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} Robin Rosenberg 2008-09-12 10:57 ` [JGIT PATCH 1/3] Fix IncorrectObjectTypeException thrown for incorrect ^{blob} Jonas Fonseca 2008-09-12 10:57 ` [JGIT PATCH 2/3] Fix off by one distance during resolving of commit~N Jonas Fonseca @ 2008-09-12 10:57 ` Jonas Fonseca 2 siblings, 0 replies; 10+ messages in thread From: Jonas Fonseca @ 2008-09-12 10:57 UTC (permalink / raw) To: Robin Rosenberg; +Cc: Shawn O. Pearce, git Fix Repository.resolve("tag^0") failing with "not a commit" (issue 23). Add test for resolving "tag^{tree}" where "tag" points to a tag Signed-off-by: Jonas Fonseca <fonseca@diku.dk> --- .../spearce/jgit/test/resources/create-second-pack | 8 +++++ ...ck-546ff360fe3488adb20860ce3436a2d6373d2796.idx | Bin 0 -> 1324 bytes ...k-546ff360fe3488adb20860ce3436a2d6373d2796.pack | Bin 0 -> 1265 bytes .../org/spearce/jgit/test/resources/packed-refs | 18 ++++++++++++ .../org/spearce/jgit/lib/RepositoryTestCase.java | 1 + .../org/spearce/jgit/lib/T0008_testparserev.java | 24 +++++++++++++--- .../src/org/spearce/jgit/lib/Repository.java | 29 ++++++++++++++++--- 7 files changed, 71 insertions(+), 9 deletions(-) create mode 100755 org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-546ff360fe3488adb20860ce3436a2d6373d2796.idx create mode 100755 org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-546ff360fe3488adb20860ce3436a2d6373d2796.pack diff --git a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack index 03f83dc..052877d 100755 --- a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack +++ b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack @@ -130,6 +130,14 @@ git tag -a -m "An annotated tag" B a^ git repack -d +Bnth=B +for nth in 2nd 3rd 4th 5th 6th 7th 8th 9th 10th; do + git tag -a -m "An $nth level annotated tag" "B$nth" "$Bnth" + Bnth="B$nth" +done + +git repack -d + git pack-refs --all diff --git a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-546ff360fe3488adb20860ce3436a2d6373d2796.idx b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-546ff360fe3488adb20860ce3436a2d6373d2796.idx new file mode 100755 index 0000000000000000000000000000000000000000..60331335d9bfa0a1830b707a36648bef5c434de9 GIT binary patch literal 1324 zcmexg;-AdGz`z8=$bb>ZAqRuZp#(Dn^^fAA69z26_@W191=>SP%my@{7MLAqE<Vfw zl&1#f1e!w;X4YY|dF;|=I?wL$m7h-!sqTEZ<d9&&_9~CduXH0eIHz>W9kWfyv-_p! zv#wIbI9*p`^SYhiW29dAUv<;y{p*xDuUg<~#xJ>b`&8x`zwBKhx4ihQ?%X{KcsVL< z*YFlFEt$`vabSO-^6v8ETNhV;zc)u{a%i8O%KaTz{TT9gzn`-G^3t<m7ehWi`_T7$ z%3Tq!Pi?N+f3xHkX!Dx8?ztTrH~0O!2|ktHQ>@q~%ak20yBn$`^kUD!HJ!YI+u~xG z#9o?rd|dq5SNQJQ6X*6S#cq>&Bkj`oHC|ie7cg9SfZ6FZFqwt|X-8nOwhV~nfyI;o zP;MHK-r4$UqjsNj$nyU7-?sZdXU_VTp1EB`)i!yC7FVXKnZSo5`dp8Uf9ZS%0H$+^ A0RR91 literal 0 HcmV?d00001 diff --git a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-546ff360fe3488adb20860ce3436a2d6373d2796.pack b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-546ff360fe3488adb20860ce3436a2d6373d2796.pack new file mode 100755 index 0000000000000000000000000000000000000000..203c157657b7f48faaaf23b794ce68264f3fd6a8 GIT binary patch literal 1265 zcmV<N1P=R9K|@Ob00062000Td33!|x%uNo0Kny_P{hXo~kWA+XBr!xhgC3wm3&a3J zNHuzU!Np6y)ywHAodPq4K)pMcA-dFaNhoApvh1r6Q^zUBC^Z}Xt^!Jf*@GKe9S;q% zK?@JKk9mU&6|X{fUFAdbI!V#xxdB9UHG1?OPPVevn0A3<0F%6B0$P@=q{9FG57Q|w z8^#HEoE?l?4#FT10RK6~UO)m}2_-ScdImiJkEM;F&@`*j+lzioGCwmdJSZ}RZ1jL3 zSQ~9H9<9qZk&Ak8Xv|1R!!hMB3jS;a>}Sz|tK;P-Gwm?J9d1k8;pF90a<>b;{kj#B zv8`v&y1z7PL^vp`ln_&e-b0}m74Wq-_DtzN{{n1~EsMqpc$^)KK?=e!5CHFa#eTrD zNeXE|#QFw(z&5+KNSc(givHf{VPGyZb$Uorpb&gw$C0N*h>Syso+%**L`QwRWABE9 zMn9W?(rg-V8Fcx{EIW*FgX>avI8yiQwAoqSv~F3tRM!(&YhAS7dJhL|Q)9*gt%ocx z$v~x4B^Cb9zhPJ{V8#h}oE?lo4uUWg1@}G0zksCQwjhZi;u-V+Eq#R;XbJfmy}jsS zlG)6Z@W3DxorTslLO^P5Xrl3Mh^~(8Y+}?&pO8Xpm3&r^_)+c9wUOy3BR1;kPPeIS zboSM=lHD$N`(>R`4Q1(wnU5_SHiizm(ORiK)85mJ7iRJ~7x9AlpML?Z4lWGF33!|x zj9UuAFc1L$bBeuyA)BWGDb_RS0n&7Bkv1u16}`RDkAeA_sl$UZ1Ko+DvN=RML~D}r z(O?cfyWq#sIjvFCama!{8v&<DG~nWS{>el;^l*dgTz5Dn`IOx3Oz*UA3&~v94iHgC zG-wPQR8UHYzCi0?p%*QXN~xTf#{c{aKCmqy#tC?w9gJNLf-n#U-+PL^fTT<LX%j=l zGw1;p`T;RO30aNaUi4v-d6`Mw1HF=uLoD(t1k@c{l$9TZA?T170nQ=#D4t>Tvw>7b zb3oTpr=N`2siiyJrnJ*pvS+4;UGSD=o00WtX^5Hgz>b}xldY{ard{diX~qjP$+{*L zMf}gdnE5T|#tC?w9gRT_!XOYu_ncxbAb}1-O^mUgK@Tv%*v7QbG^5emi!NUBHt+u$ zADjfN4JL*_uFuHS<$WKGL+|=%IeE<9ct*aHlF!N@G^z$%oJ>C%d4mCNaGmM~N77F% z&CdL$Wt~~4x}4gB?G6?#BJ4~sMya7d>tW^>&p@SAA>sTV{{lSeEjGppc$^)KK@P$o z5CHGIVm}~ZSy~`5#`*?*z!tVOrY%i_Mt^VhFv(nIO8<~l!J<nnK3YfAdYf(NiKUN& zZxXTuH{`~(HmLep1uBnf2QIYbpNz6W2RFFh%LYf*PhEFA%bVwQ5}nF?0z|YC35nof zyfI333+z2i@{$R7SxV(9`9J>xFz+o1#tC?w9gIN=!Y~j3?|H?3z_OcEvjq|B8}tF2 zWT{A-loCaMZ}c!QmzfeC8Y__Z2S!G*jyNVBLXbXkV9&1ak<{X__vlRhtO`{o(}0W3 z=_iwJFv1P4_p-rJx@T9Lo%JotI%^lpasnc<137XIcIXj}88fsVW_{@ll5?q2HT~yb by>=`Kh3c^@jzd(ZkB9p`zw>FD_Gf9gVWLq? literal 0 HcmV?d00001 diff --git a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/packed-refs b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/packed-refs index f67a3ef..746bd6b 100644 --- a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/packed-refs +++ b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/packed-refs @@ -9,5 +9,23 @@ d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 refs/heads/pa 6db9c2ebf75590eef973081736730a9ea169a0c4 refs/tags/A 17768080a2318cd89bba4c8b87834401e2095703 refs/tags/B ^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 +032c063ce34486359e3ee3d4f9e5c225b9e1a4c2 refs/tags/B10th +^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 +214cae792433672d28b3aeb9f75c1ae84fd54628 refs/tags/B2nd +^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 +1170b77a48d3ea2d58b043648b1ec63d606e3efa refs/tags/B3rd +^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 +8dfd42699e7b10e568fa1eaebe249e33e98da81e refs/tags/B4th +^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 +efee904c794b943a06931c76c576dd552212e8bc refs/tags/B5th +^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 +d54e006ebbef94b7d3a5cd56d154f1e6f08efb94 refs/tags/B6th +^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 +a773cd2d9dbca00d08793dac0d7002a49f0428c0 refs/tags/B7th +^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 +bf5123bb77c7b5a379f7de9c1293558e3e24dfb8 refs/tags/B8th +^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 +dd144af286452bfd6a1ea02b0d3745bcdb555e9d refs/tags/B9th +^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 8bbde7aacf771a9afb6992434f1ae413e010c6d8 refs/tags/spearce-gpg-pub ^fd608fbe625a2b456d9f15c2b1dc41f252057dd7 diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java index 270b90a..9d7d133 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java @@ -141,6 +141,7 @@ public void run() { "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f", "pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371", "pack-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745", + "pack-546ff360fe3488adb20860ce3436a2d6373d2796", "pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa" }; final File packDir = new File(db.getObjectsDirectory(), "pack"); diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java index 506f51f..47105cf 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java @@ -106,14 +106,30 @@ public void testDerefCommit() throws IOException { } public void testDerefTag() throws IOException { - assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("spearce-gpg-pub^{}").name()); - assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("spearce-gpg-pub^{blob}").name()); + assertEquals("17768080a2318cd89bba4c8b87834401e2095703",db.resolve("refs/tags/B").name()); + assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/B^{commit}").name()); + assertEquals("032c063ce34486359e3ee3d4f9e5c225b9e1a4c2",db.resolve("refs/tags/B10th").name()); + assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/B10th^{commit}").name()); + assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/B10th^{}").name()); + 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("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()); } public void testDerefBlob() throws IOException { + assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("spearce-gpg-pub^{}").name()); + assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("spearce-gpg-pub^{blob}").name()); assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("fd608fbe625a2b456d9f15c2b1dc41f252057dd7^{}").name()); assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("fd608fbe625a2b456d9f15c2b1dc41f252057dd7^{blob}").name()); } - - // TODO: ^{tree} for a tag pointing to a tag + + public void testDerefTree() throws IOException { + assertEquals("032c063ce34486359e3ee3d4f9e5c225b9e1a4c2",db.resolve("refs/tags/B10th").name()); + assertEquals("856ec208ae6cadac25a6d74f19b12bb27a24fe24",db.resolve("032c063ce34486359e3ee3d4f9e5c225b9e1a4c2^{tree}").name()); + assertEquals("856ec208ae6cadac25a6d74f19b12bb27a24fe24",db.resolve("refs/tags/B10th^{tree}").name()); + } + } diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java index 894fe3b..dfce1b8 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java @@ -562,6 +562,11 @@ public ObjectId resolve(final String revstr) throws IOException { case '9': int j; ref = mapObject(refId, null); + while (ref instanceof Tag) { + Tag tag = (Tag)ref; + refId = tag.getObjId(); + ref = mapObject(refId, null); + } if (!(ref instanceof Commit)) throw new IncorrectObjectTypeException(refId, Constants.TYPE_COMMIT); for (j=i+1; j<rev.length; ++j) { @@ -632,10 +637,10 @@ else if (item.equals("blob")) { } else if (item.equals("")) { ref = mapObject(refId, null); - if (ref instanceof Tag) - refId = ((Tag)ref).getObjId(); - else { - // self + while (ref instanceof Tag) { + Tag t = (Tag)ref; + refId = t.getObjId(); + ref = mapObject(refId, null); } } else @@ -658,6 +663,11 @@ else if (item.equals("")) { } } else { ref = mapObject(refId, null); + while (ref instanceof Tag) { + Tag tag = (Tag)ref; + refId = tag.getObjId(); + ref = mapObject(refId, null); + } if (ref instanceof Commit) { final ObjectId parents[] = ((Commit) ref) .getParentIds(); @@ -673,8 +683,17 @@ else if (item.equals("")) { if (ref == null) { String refstr = new String(rev,0,i); refId = resolveSimple(refstr); - ref = mapCommit(refId); + if (refId == null) + return null; + ref = mapObject(refId, null); + } + while (ref instanceof Tag) { + Tag tag = (Tag)ref; + refId = tag.getObjId(); + ref = mapObject(refId, null); } + if (!(ref instanceof Commit)) + throw new IncorrectObjectTypeException(refId, Constants.TYPE_COMMIT); int l; for (l = i + 1; l < rev.length; ++l) { if (!Character.isDigit(rev[l])) -- 1.6.0.1.451.gc8d31 -- Jonas Fonseca ^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-09-12 14:48 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-09-11 21:39 [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} Jonas Fonseca 2008-09-11 22:47 ` Robin Rosenberg 2008-09-12 0:00 ` Jonas Fonseca 2008-09-12 1:51 ` Imran M Yousuf 2008-09-12 8:40 ` [JGIT PATCH] Configure the maven surefire plugin to specifically include all tests Jonas Fonseca 2008-09-12 14:47 ` Shawn O. Pearce 2008-09-12 6:47 ` [JGIT PATCH 1/2] Issue 23: Resolve tag^0 as tag^{commit} Robin Rosenberg 2008-09-12 10:57 ` [JGIT PATCH 1/3] Fix IncorrectObjectTypeException thrown for incorrect ^{blob} Jonas Fonseca 2008-09-12 10:57 ` [JGIT PATCH 2/3] Fix off by one distance during resolving of commit~N Jonas Fonseca 2008-09-12 10:57 ` [JGIT PATCH 3/3] Tests and fixes for dereferencing tags in Repository.resolve() Jonas Fonseca
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).