Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] Bug in TreeWalk.forPath (?)

Hi,

I am using JGit 0.10.1 from Maven. In certain occasions, such as the one documented in the following JUnit test case, JGit recognises a file path as either a directory or file, depending on whether TreeWalk.forPath() is used or not. Is it a bug in forPath() or am I missing something on how to use it?

--
Giorgos

String repo = "/home/gousiosg/test"; //Clone of git://github.com/schacon/ruby-git.git
        Repository local = new FileRepository(repo);
        FileMode a = null, b = null;
        RevWalk rw = new RevWalk(local);
ObjectId treeId = local.resolve("5df04c8b946ef9c1f31bf8e722a9262b512c1928");

        RevTree tree = rw.parseTree(treeId);
        final TreeWalk walk = new TreeWalk(local);
        walk.setRecursive(false);
        walk.addTree(tree);

        while (walk.next()) {
            String pathstr = walk.getPathString();
            if (pathstr.equals("working")) {
                a = walk.getFileMode(0);
                break;
            }
        }

        assertNotNull(a);
        assertEquals(a, FileMode.TREE);

RevCommit c = rw.parseCommit(local.resolve("b18bca3b853dee6a7bc86f09921aa3b1ee3f3d7b")); TreeWalk tw = TreeWalk.forPath(local, "tests/files/working", c.getTree());
        b = tw.getFileMode(0);

        assertNotNull(b);
        assertEquals(b, FileMode.REGULAR_FILE);
        assertEquals(a, b); // <-- Obviously, fails here


Back to the top