diff options
author | Philipp Thun <philipp.thun@sap.com> | 2010-12-14 11:31:41 +0100 |
---|---|---|
committer | Philipp Thun <philipp.thun@sap.com> | 2010-12-14 11:31:41 +0100 |
commit | bab053afddbbc26203da54af2dface6ed657f116 (patch) | |
tree | dd78fc781524a320a327416f78b1148139cb25a9 /org.eclipse.jgit.test | |
parent | c6ca443b61372d73a7f1438c995713bad39b5277 (diff) | |
download | jgit-bab053afddbbc26203da54af2dface6ed657f116.tar.gz jgit-bab053afddbbc26203da54af2dface6ed657f116.zip |
Do not rely on filemode differences in case of symbolic links
When checking whether a file in the working tree has been modified -
WorkingTreeIterator.isModified() - we should not trust the filemode
in case of symbolic links, but check the timestamp and also the
content, if requested. Without this fix symlinks will always be shown
in EGit as modified files on Windows systems.
Change-Id: I367c807df5a7e85e828ddacff7fee7901441f187
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java | 21 |
1 files changed, 21 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 22eeb8e3d3..67fae270eb 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 @@ -46,6 +46,9 @@ package org.eclipse.jgit.treewalk; import java.io.File; import java.security.MessageDigest; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.dircache.DirCacheCheckout; +import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.ObjectId; @@ -175,6 +178,24 @@ public class FileTreeIteratorTest extends RepositoryTestCase { assertEquals(expect, top.getEntryObjectId()); } + public void testIsModifiedSymlink() throws Exception { + File f = writeTrashFile("symlink", "content"); + Git git = new Git(db); + git.add().addFilepattern("symlink").call(); + git.commit().setMessage("commit").call(); + + // Modify previously committed DirCacheEntry and write it back to disk + DirCacheEntry dce = db.readDirCache().getEntry("symlink"); + dce.setFileMode(FileMode.SYMLINK); + DirCacheCheckout.checkoutEntry(db, f, dce); + + FileTreeIterator fti = new FileTreeIterator(trash, db.getFS(), db + .getConfig().get(WorkingTreeOptions.KEY)); + while (!fti.getEntryPathString().equals("symlink")) + fti.next(1); + assertFalse(fti.isModified(dce, false)); + } + private static String nameOf(final AbstractTreeIterator i) { return RawParseUtils.decode(Constants.CHARSET, i.path, 0, i.pathLen); } |