summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2012-05-21 10:48:40 -0700
committerKevin Sawicki <kevin@github.com>2012-05-21 10:48:40 -0700
commit1953ae6aeec51dafedadb0fdb3f352ed4d027f45 (patch)
treef4a39a4a35380b5c5d9d50ee2d553b333fd92205 /org.eclipse.jgit.test
parent15147a273fc9085ca3cf459dec42f7a88b22ffbf (diff)
downloadjgit-1953ae6aeec51dafedadb0fdb3f352ed4d027f45.tar.gz
jgit-1953ae6aeec51dafedadb0fdb3f352ed4d027f45.zip
Smudge index entries on first write (too), as well when reading
That happens when the index and a new file is created within the same second and becomes a problem if we then modify the newly created file within the same second after adding it to the index. Without smudging JGit will, on later reads, think the file is unchanged. The accompanying test passed with the smuding on read. Change-Id: I4dfecf5c93993ef690e7f0dddb3f3e6125daae15
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java22
1 files changed, 22 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 064100839e..b335f2d43a 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
@@ -64,6 +64,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.treewalk.WorkingTreeIterator.MetadataDiff;
import org.eclipse.jgit.treewalk.filter.PathFilter;
import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.RawParseUtils;
@@ -216,6 +217,27 @@ public class FileTreeIteratorTest extends RepositoryTestCase {
}
@Test
+ public void testIsModifiedFileSmudged() throws Exception {
+ File f = writeTrashFile("file", "content");
+ Git git = new Git(db);
+ // The idea of this test is to check the smudged handling
+ // Hopefully fsTick will make sure our entry gets smudged
+ fsTick(f);
+ writeTrashFile("file", "content");
+ git.add().addFilepattern("file").call();
+ writeTrashFile("file", "conten2");
+ DirCacheEntry dce = db.readDirCache().getEntry("file");
+ FileTreeIterator fti = new FileTreeIterator(trash, db.getFS(), db
+ .getConfig().get(WorkingTreeOptions.KEY));
+ while (!fti.getEntryPathString().equals("file"))
+ fti.next(1);
+ // If the fsTick trick does not work we could skip the compareMetaData
+ // test and hope that we are usually testing the intended code path.
+ assertEquals(MetadataDiff.SMUDGED, fti.compareMetadata(dce));
+ assertTrue(fti.isModified(dce, false));
+ }
+
+ @Test
public void submoduleHeadMatchesIndex() throws Exception {
Git git = new Git(db);
writeTrashFile("file.txt", "content");