diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-08-15 14:33:16 +0200 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-08-15 20:20:48 +0200 |
commit | 342de38e57e3052d3d2f12e93d629bdc63f123be (patch) | |
tree | 0aff9a482f9d624c22ec40454f4679b941805c97 /org.eclipse.jgit.test | |
parent | 02113f7411df6d680aa520803ac8c63009696c3a (diff) | |
download | jgit-342de38e57e3052d3d2f12e93d629bdc63f123be.tar.gz jgit-342de38e57e3052d3d2f12e93d629bdc63f123be.zip |
Fix idOffset when the working tree iterator matches a dircache entry
idOffset is not zero when idBuffer comes from blob in the dircache
Change-Id: Iff768422cba140a5d6a776e2c627b852f079c1da
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java index 2cdaea28de..209b2b8377 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java @@ -198,6 +198,31 @@ public class FileTreeIteratorTest extends RepositoryTestCase { } @Test + public void testDirCacheMatchingId() throws Exception { + File f = writeTrashFile("file", "content"); + Git git = new Git(db); + writeTrashFile("file", "content"); + fsTick(f); + git.add().addFilepattern("file").call(); + DirCacheEntry dce = db.readDirCache().getEntry("file"); + TreeWalk tw = new TreeWalk(db); + FileTreeIterator fti = new FileTreeIterator(trash, db.getFS(), db + .getConfig().get(WorkingTreeOptions.KEY)); + tw.addTree(fti); + DirCacheIterator dci = new DirCacheIterator(db.readDirCache()); + tw.addTree(dci); + fti.setDirCacheIterator(tw, 1); + while (tw.next() && !tw.getPathString().equals("file")) { + // + } + assertEquals(MetadataDiff.EQUAL, fti.compareMetadata(dce)); + ObjectId fromRaw = ObjectId.fromRaw(fti.idBuffer(), fti.idOffset()); + assertEquals("6b584e8ece562ebffc15d38808cd6b98fc3d97ea", + fromRaw.getName()); + assertFalse(fti.isModified(dce, false)); + } + + @Test public void testIsModifiedSymlink() throws Exception { File f = writeTrashFile("symlink", "content"); Git git = new Git(db); |