{"thread":{"id":"17513","subject":"[JGIT PATCH] Fix AbstractTreeIterator path comparion betwen 'a' and 'a/b'","startedAt":"2009-02-02T20:13:37Z","lastAt":"2009-02-03T17:20:23Z","messageCount":7,"participants":["Tor Arne Vestbø","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"102888","messageId":"1233605617-14513-1-git-send-email-torarnv@gmail.com","threadId":"17513","inReplyTo":null,"subject":"[JGIT PATCH] Fix AbstractTreeIterator path comparion betwen 'a' and 'a/b'","fromName":"Tor Arne Vestbø","fromEmail":"torarnv@gmail.com","sentAt":"2009-02-02T20:13:37Z","receivedAt":"2009-02-02T20:13:37Z","isPatch":true,"sender":{"key":"torarnv@gmail.com","avatar":"https://gravatar.com/avatar/847af0150a5a28ad86d9db1556a48aba04e7642c6a29a5a767f8c2bdf1720321?d=mp&s=160"},"body":"The occurance of a '/' as the next character in the longer path\ndoes not neccecarily mean the two paths are equal, for example\nwhen the longer path has more components following the '/'.\n\nSigned-off-by: Tor Arne Vestbø <torarnv@gmail.com>\n---\n .../jgit/treewalk/AbstractTreeIteratorTest.java    |   93 ++++++++++++++++++++\n .../jgit/treewalk/AbstractTreeIterator.java        |    4 +-\n 2 files changed, 95 insertions(+), 2 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java\nnew file mode 100644\nindex 0000000..4c74094\n--- /dev/null\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java\n@@ -0,0 +1,93 @@\n+/*\n+ * Copyright (C) 2009, Tor Arne Vestbø <torarnv@gmail.com>\n+ *\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or\n+ * without modification, are permitted provided that the following\n+ * conditions are met:\n+ *\n+ * - Redistributions of source code must retain the above copyright\n+ *   notice, this list of conditions and the following disclaimer.\n+ *\n+ * - Redistributions in binary form must reproduce the above\n+ *   copyright notice, this list of conditions and the following\n+ *   disclaimer in the documentation and/or other materials provided\n+ *   with the distribution.\n+ *\n+ * - Neither the name of the Git Development Community nor the\n+ *   names of its contributors may be used to endorse or promote\n+ *   products derived from this software without specific prior\n+ *   written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\n+ * CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,\n+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+package org.spearce.jgit.treewalk;\n+\n+import java.io.IOException;\n+\n+import org.spearce.jgit.errors.IncorrectObjectTypeException;\n+import org.spearce.jgit.lib.FileMode;\n+import org.spearce.jgit.lib.Repository;\n+import org.spearce.jgit.lib.RepositoryTestCase;\n+\n+\n+public class AbstractTreeIteratorTest extends RepositoryTestCase {\n+\n+\n+\tpublic class FakeTreeIterator extends WorkingTreeIterator {\n+\t\tpublic FakeTreeIterator(String path, FileMode fileMode) {\n+\t\t\tsuper(path);\n+\t\t\tmode = fileMode.getBits();\n+\t\t\tpathLen -= 1; // Get rid of extra '/'\n+\t\t}\n+\n+\t\t@Override\n+\t\tpublic AbstractTreeIterator createSubtreeIterator(Repository repo)\n+\t\t\t\tthrows IncorrectObjectTypeException, IOException {\n+\t\t\treturn null;\n+\t\t}\n+\n+\t}\n+\n+\tpublic void testPathCompare() throws Exception {\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a/b\", FileMode.REGULAR_FILE)) < 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a//\", FileMode.TREE)) == 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a/b\", FileMode.REGULAR_FILE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) > 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a//\", FileMode.TREE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) == 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.REGULAR_FILE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) < 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.REGULAR_FILE)) > 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.REGULAR_FILE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.REGULAR_FILE)) == 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) == 0);\n+\t}\n+\n+}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java\nindex 2ff3b99..7dd3f38 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java\n@@ -289,9 +289,9 @@ int pathCompare(final AbstractTreeIterator p, final int pMode) {\n \t\t}\n \n \t\tif (cPos < aLen)\n-\t\t\treturn (a[cPos] & 0xff) - lastPathChar(pMode);\n+\t\t\treturn ((a[cPos] & 0xff) - lastPathChar(pMode)) + (aLen - cPos - 1);\n \t\tif (cPos < bLen)\n-\t\t\treturn lastPathChar(mode) - (b[cPos] & 0xff);\n+\t\t\treturn (lastPathChar(mode) - (b[cPos] & 0xff)) - (bLen - cPos - 1);\n \t\treturn lastPathChar(mode) - lastPathChar(pMode);\n \t}\n \n-- \n1.6.1.2.309.g2ea3\n"},{"id":"102979","messageId":"20090203161539.GV26880@spearce.org","threadId":"17513","inReplyTo":"1233605617-14513-1-git-send-email-torarnv@gmail.com","subject":"Re: [JGIT PATCH] Fix AbstractTreeIterator path comparion betwen 'a' and 'a/b'","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-03T16:15:39Z","receivedAt":"2009-02-03T16:15:39Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Tor Arne Vestbø <torarnv@gmail.com> wrote:\n> The occurance of a '/' as the next character in the longer path\n> does not neccecarily mean the two paths are equal, for example\n> when the longer path has more components following the '/'.\n> \n> Signed-off-by: Tor Arne Vestbø <torarnv@gmail.com>\n> ---\n>  .../jgit/treewalk/AbstractTreeIteratorTest.java    |   93 ++++++++++++++++++++\n>  .../jgit/treewalk/AbstractTreeIterator.java        |    4 +-\n>  2 files changed, 95 insertions(+), 2 deletions(-)\n>  create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java\n\n*sigh*\n\nI can't get Eclipse to run this test.  Every time I try it comes\nup with a CNFE:\n\n  Class not found org.spearce.jgit.treewalk.AbstractTreeIteratorTest\n  java.lang.ClassNotFoundException: org.spearce.jgit.treewalk.AbstractTreeIteratorTest\n    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)\n\nAside from this test not running, Eclipse says the tests pass.  But\nMaven tells another story:\n\n  (cd jgit-maven/jgit && mvn clean package)\n  ...\n  Failed tests:\n    testNoDF_NoGap(org.spearce.jgit.treewalk.NameConflictTreeWalkTest)\n    testDF_GapByOne(org.spearce.jgit.treewalk.NameConflictTreeWalkTest)\n    testDF_SkipsSeenSubtree(org.spearce.jgit.treewalk.NameConflictTreeWalkTest)\n\n  Tests run: 773, Failures: 3, Errors: 0, Skipped: 0\n\nYet under Eclipse this test says its fine.  But Maven actually\nmanaged to run your new test case, where Eclipse didn't.\n\n*confused*\n \n-- \nShawn.\n"},{"id":"102982","messageId":"49887274.8040601@gmail.com","threadId":"17513","inReplyTo":"20090203161539.GV26880@spearce.org","subject":"Re: [JGIT PATCH] Fix AbstractTreeIterator path comparion betwen 'a' and 'a/b'","fromName":"Tor Arne Vestbø","fromEmail":"torarnv@gmail.com","sentAt":"2009-02-03T16:36:04Z","receivedAt":"2009-02-03T16:36:04Z","isPatch":true,"sender":{"key":"torarnv@gmail.com","avatar":"https://gravatar.com/avatar/847af0150a5a28ad86d9db1556a48aba04e7642c6a29a5a767f8c2bdf1720321?d=mp&s=160"},"body":"Shawn O. Pearce wrote:\n> Aside from this test not running, Eclipse says the tests pass.  But\n> Maven tells another story: Tests run: 773, Failures: 3, Errors: 0\n\nStrange :/\n\nNevertheless, there shouldn't be any failures, I see all three of them\nwhen running in Eclipse, so I messed up, sorry for that. Will fix ASAP.\n\nTor Arne\n"},{"id":"102986","messageId":"20090203165712.GW26880@spearce.org","threadId":"17513","inReplyTo":"20090203161539.GV26880@spearce.org","subject":"Re: [JGIT PATCH] Fix AbstractTreeIterator path comparion betwen 'a' and 'a/b'","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-03T16:57:12Z","receivedAt":"2009-02-03T16:57:12Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> wrote:\n> Tor Arne Vestbø <torarnv@gmail.com> wrote:\n> > The occurance of a '/' as the next character in the longer path\n> > does not neccecarily mean the two paths are equal, for example\n> > when the longer path has more components following the '/'.\n> > \n> > Signed-off-by: Tor Arne Vestbø <torarnv@gmail.com>\n> > ---\n> >  .../jgit/treewalk/AbstractTreeIteratorTest.java    |   93 ++++++++++++++++++++\n> >  .../jgit/treewalk/AbstractTreeIterator.java        |    4 +-\n> >  2 files changed, 95 insertions(+), 2 deletions(-)\n> >  create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java\n> \n> *sigh*\n> \n> I can't get Eclipse to run this test.  Every time I try it comes\n> up with a CNFE:\n\n@#*@!#@!!@*@ MAVEN ECLIPSE PLUGIN.\n\nThe Maven Eclipse plugin, which shouldn't have even been invoked\nbecause JGit doesn't use Maven within Eclipse, was crashing and\ncausing the JDT to stop compiling.  No records was reported in\nthe Problems view, but my Error Log was full of JDT crashes due\nto ClassCastExceptions.  Uninstalling the Maven plugin fixed the\nbuild and made Eclipse come up with the same failures:\n\n>   Failed tests:\n>     testNoDF_NoGap(org.spearce.jgit.treewalk.NameConflictTreeWalkTest)\n>     testDF_GapByOne(org.spearce.jgit.treewalk.NameConflictTreeWalkTest)\n>     testDF_SkipsSeenSubtree(org.spearce.jgit.treewalk.NameConflictTreeWalkTest)\n> \n>   Tests run: 773, Failures: 3, Errors: 0, Skipped: 0\n\nSo at least my workbench is now reporting the same as Maven on\nthe command line.  But elsewhere I use Maven (different workbench,\nsame Eclipse installation) so now I've just shot myself in the foot\nand need to install a duplicate copy of Eclipse.  Whoopie.\n\n</unrelated-to-your-patch>\n\nI'm quite certain the breakage in testNoDF_NoGap on line 86 of\nNameConflictTreeWalkTest is caused by your change.  Your code is\nmaking \"a.b\" (a file) equal to \"a/\" (a tree).  That can't be right.\n\nGoing back through the code, the old version of pathCompare\nstill seems right to me.  And your test cases are somewhat\nbroken.  We shouldn't ever be looking at cases like this:\n\n  assertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n             new FakeTreeIterator(\"a/b\", FileMode.REGULAR_FILE)) < 0);\n\nThere's no such thing as a tree entry with '/' in the name.  Really\nthis should have been:\n\n  assertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n             new FakeTreeIterator(\"a\", FileMode.TREE)) < 0);\n\nat which point they must be equal, because they are both a tree\nnamed \"a\".  So that throws off a good chunk of your new test cases.\nI don't know how I missed this yesterday when you showed me a version\nof the tests, but I did.  We should never be doing a compare of\n\"a/b\" in the pathCompare method.\n\n-- \nShawn.\n"},{"id":"102989","messageId":"20090203170337.GX26880@spearce.org","threadId":"17513","inReplyTo":"49887274.8040601@gmail.com","subject":"Re: [JGIT PATCH] Fix AbstractTreeIterator path comparion betwen 'a' and 'a/b'","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-03T17:03:37Z","receivedAt":"2009-02-03T17:03:37Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Tor Arne Vestbø <torarnv@gmail.com> wrote:\n> Shawn O. Pearce wrote:\n> > Aside from this test not running, Eclipse says the tests pass.  But\n> > Maven tells another story: Tests run: 773, Failures: 3, Errors: 0\n> \n> Strange :/\n> \n> Nevertheless, there shouldn't be any failures, I see all three of them\n> when running in Eclipse, so I messed up, sorry for that. Will fix ASAP.\n\nOK, so I think this is a valid test case, and as it turns out,\nit passes with the library unmodified:\n\n--8<--\n+\tpublic void testPathCompare() throws Exception {\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) == 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.REGULAR_FILE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.REGULAR_FILE)) == 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.REGULAR_FILE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) < 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.REGULAR_FILE)) > 0);\n+\t}\n----\n\nWhich means whatever problem you have been seeing in the decorator\ncode is different than what we were originally thinking.  Perhaps you\nare trying to use the tree iterator APIs in a way that they aren't\nmeant to be used (like passing in full paths where only a path name\ncomponent is expected?), or there is something else lurking that\nwe don't understand.\n\n-- \nShawn.\n"},{"id":"102991","messageId":"49887A86.2040602@gmail.com","threadId":"17513","inReplyTo":"20090203170337.GX26880@spearce.org","subject":"Re: [JGIT PATCH] Fix AbstractTreeIterator path comparion betwen 'a' and 'a/b'","fromName":"Tor Arne Vestbø","fromEmail":"torarnv@gmail.com","sentAt":"2009-02-03T17:10:30Z","receivedAt":"2009-02-03T17:10:30Z","isPatch":true,"sender":{"key":"torarnv@gmail.com","avatar":"https://gravatar.com/avatar/847af0150a5a28ad86d9db1556a48aba04e7642c6a29a5a767f8c2bdf1720321?d=mp&s=160"},"body":"Shawn O. Pearce wrote:\n> OK, so I think this is a valid test case, and as it turns out,\n> it passes with the library unmodified:\n> \n> --8<--\n> +\tpublic void testPathCompare() throws Exception {\n> +\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n> +\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) == 0);\n> +\n> +\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.REGULAR_FILE).pathCompare(\n> +\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.REGULAR_FILE)) == 0);\n> +\n> +\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.REGULAR_FILE).pathCompare(\n> +\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) < 0);\n> +\n> +\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n> +\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.REGULAR_FILE)) > 0);\n> +\t}\n> ----\n\nOkey, I'll post a new patch with just those test cases, no changes to\nthe pathCompare, so we at least have those tests.\n\n> Which means whatever problem you have been seeing in the decorator\n> code is different than what we were originally thinking.  Perhaps you\n> are trying to use the tree iterator APIs in a way that they aren't\n> meant to be used (like passing in full paths where only a path name\n> component is expected?), or there is something else lurking that\n> we don't understand.\n\n\nAhh, I see. My patch was based on the assumption that 'a/b' was a valid\ncomparison, since I was seeing similar comparisons in live code. But as\nyou say, that's probably due to how I use the iterators. I will go back\nand investigate how I ended up with 'a/b' paths in the first place.\n\nThanks :)\n\nTor Arne\n"},{"id":"102995","messageId":"1233681623-22011-1-git-send-email-torarnv@gmail.com","threadId":"17513","inReplyTo":"49887A86.2040602@gmail.com","subject":"[JGIT PATCH v2] Add a few test cases for AbstractTreeIterator's pathCompare","fromName":"Tor Arne Vestbø","fromEmail":"torarnv@gmail.com","sentAt":"2009-02-03T17:20:23Z","receivedAt":"2009-02-03T17:20:23Z","isPatch":true,"sender":{"key":"torarnv@gmail.com","avatar":"https://gravatar.com/avatar/847af0150a5a28ad86d9db1556a48aba04e7642c6a29a5a767f8c2bdf1720321?d=mp&s=160"},"body":"Tests that files sort before trees if the path is the same, and\nthat if both path and mode is the same, they are considered equal.\n\nSigned-off-by: Tor Arne Vestbø <torarnv@gmail.com>\n---\n .../jgit/treewalk/AbstractTreeIteratorTest.java    |   80 ++++++++++++++++++++\n 1 files changed, 80 insertions(+), 0 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java\nnew file mode 100644\nindex 0000000..d45e22c\n--- /dev/null\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/AbstractTreeIteratorTest.java\n@@ -0,0 +1,80 @@\n+/*\n+ * Copyright (C) 2009, Tor Arne Vestbø <torarnv@gmail.com>\n+ *\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or\n+ * without modification, are permitted provided that the following\n+ * conditions are met:\n+ *\n+ * - Redistributions of source code must retain the above copyright\n+ *   notice, this list of conditions and the following disclaimer.\n+ *\n+ * - Redistributions in binary form must reproduce the above\n+ *   copyright notice, this list of conditions and the following\n+ *   disclaimer in the documentation and/or other materials provided\n+ *   with the distribution.\n+ *\n+ * - Neither the name of the Git Development Community nor the\n+ *   names of its contributors may be used to endorse or promote\n+ *   products derived from this software without specific prior\n+ *   written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\n+ * CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,\n+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+package org.spearce.jgit.treewalk;\n+\n+import java.io.IOException;\n+\n+import org.spearce.jgit.errors.IncorrectObjectTypeException;\n+import org.spearce.jgit.lib.FileMode;\n+import org.spearce.jgit.lib.Repository;\n+import org.spearce.jgit.lib.RepositoryTestCase;\n+\n+\n+public class AbstractTreeIteratorTest extends RepositoryTestCase {\n+\n+\n+\tpublic class FakeTreeIterator extends WorkingTreeIterator {\n+\t\tpublic FakeTreeIterator(String path, FileMode fileMode) {\n+\t\t\tsuper(path);\n+\t\t\tmode = fileMode.getBits();\n+\t\t\tpathLen -= 1; // Get rid of extra '/'\n+\t\t}\n+\n+\t\t@Override\n+\t\tpublic AbstractTreeIterator createSubtreeIterator(Repository repo)\n+\t\t\t\tthrows IncorrectObjectTypeException, IOException {\n+\t\t\treturn null;\n+\t\t}\n+\n+\t}\n+\n+\tpublic void testPathCompare() throws Exception {\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.REGULAR_FILE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) < 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.REGULAR_FILE)) > 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.REGULAR_FILE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.REGULAR_FILE)) == 0);\n+\n+\t\tassertTrue(new FakeTreeIterator(\"a\", FileMode.TREE).pathCompare(\n+\t\t\t\tnew FakeTreeIterator(\"a\", FileMode.TREE)) == 0);\n+\t}\n+\n+}\n-- \n1.6.1.2.309.g2ea3\n"}]}