|
|
@ -49,80 +49,81 @@ public class IndexModificationTimesTest extends RepositoryTestCase { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testLastModifiedTimes() throws Exception { |
|
|
|
public void testLastModifiedTimes() throws Exception { |
|
|
|
Git git = new Git(db); |
|
|
|
try (Git git = new Git(db)) { |
|
|
|
String path = "file"; |
|
|
|
String path = "file"; |
|
|
|
writeTrashFile(path, "content"); |
|
|
|
writeTrashFile(path, "content"); |
|
|
|
String path2 = "file2"; |
|
|
|
String path2 = "file2"; |
|
|
|
writeTrashFile(path2, "content2"); |
|
|
|
writeTrashFile(path2, "content2"); |
|
|
|
|
|
|
|
|
|
|
|
git.add().addFilepattern(path).call(); |
|
|
|
git.add().addFilepattern(path).call(); |
|
|
|
git.add().addFilepattern(path2).call(); |
|
|
|
git.add().addFilepattern(path2).call(); |
|
|
|
git.commit().setMessage("commit").call(); |
|
|
|
git.commit().setMessage("commit").call(); |
|
|
|
|
|
|
|
|
|
|
|
DirCache dc = db.readDirCache(); |
|
|
|
DirCache dc = db.readDirCache(); |
|
|
|
DirCacheEntry entry = dc.getEntry(path); |
|
|
|
DirCacheEntry entry = dc.getEntry(path); |
|
|
|
DirCacheEntry entry2 = dc.getEntry(path); |
|
|
|
DirCacheEntry entry2 = dc.getEntry(path); |
|
|
|
|
|
|
|
|
|
|
|
assertTrue("last modified shall not be zero!", |
|
|
|
assertTrue("last modified shall not be zero!", |
|
|
|
entry.getLastModified() != 0); |
|
|
|
entry.getLastModified() != 0); |
|
|
|
|
|
|
|
|
|
|
|
assertTrue("last modified shall not be zero!", |
|
|
|
assertTrue("last modified shall not be zero!", |
|
|
|
entry2.getLastModified() != 0); |
|
|
|
entry2.getLastModified() != 0); |
|
|
|
|
|
|
|
|
|
|
|
writeTrashFile(path, "new content"); |
|
|
|
writeTrashFile(path, "new content"); |
|
|
|
git.add().addFilepattern(path).call(); |
|
|
|
git.add().addFilepattern(path).call(); |
|
|
|
git.commit().setMessage("commit2").call(); |
|
|
|
git.commit().setMessage("commit2").call(); |
|
|
|
|
|
|
|
|
|
|
|
dc = db.readDirCache(); |
|
|
|
dc = db.readDirCache(); |
|
|
|
entry = dc.getEntry(path); |
|
|
|
entry = dc.getEntry(path); |
|
|
|
entry2 = dc.getEntry(path); |
|
|
|
entry2 = dc.getEntry(path); |
|
|
|
|
|
|
|
|
|
|
|
assertTrue("last modified shall not be zero!", |
|
|
|
assertTrue("last modified shall not be zero!", |
|
|
|
entry.getLastModified() != 0); |
|
|
|
entry.getLastModified() != 0); |
|
|
|
|
|
|
|
|
|
|
|
assertTrue("last modified shall not be zero!", |
|
|
|
assertTrue("last modified shall not be zero!", |
|
|
|
entry2.getLastModified() != 0); |
|
|
|
entry2.getLastModified() != 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testModify() throws Exception { |
|
|
|
public void testModify() throws Exception { |
|
|
|
Git git = new Git(db); |
|
|
|
try (Git git = new Git(db)) { |
|
|
|
String path = "file"; |
|
|
|
String path = "file"; |
|
|
|
writeTrashFile(path, "content"); |
|
|
|
writeTrashFile(path, "content"); |
|
|
|
|
|
|
|
|
|
|
|
git.add().addFilepattern(path).call(); |
|
|
|
git.add().addFilepattern(path).call(); |
|
|
|
git.commit().setMessage("commit").call(); |
|
|
|
git.commit().setMessage("commit").call(); |
|
|
|
|
|
|
|
|
|
|
|
DirCache dc = db.readDirCache(); |
|
|
|
DirCache dc = db.readDirCache(); |
|
|
|
DirCacheEntry entry = dc.getEntry(path); |
|
|
|
DirCacheEntry entry = dc.getEntry(path); |
|
|
|
|
|
|
|
|
|
|
|
long masterLastMod = entry.getLastModified(); |
|
|
|
long masterLastMod = entry.getLastModified(); |
|
|
|
|
|
|
|
|
|
|
|
git.checkout().setCreateBranch(true).setName("side").call(); |
|
|
|
git.checkout().setCreateBranch(true).setName("side").call(); |
|
|
|
|
|
|
|
|
|
|
|
Thread.sleep(10); |
|
|
|
Thread.sleep(10); |
|
|
|
String path2 = "file2"; |
|
|
|
String path2 = "file2"; |
|
|
|
writeTrashFile(path2, "side content"); |
|
|
|
writeTrashFile(path2, "side content"); |
|
|
|
git.add().addFilepattern(path2).call(); |
|
|
|
git.add().addFilepattern(path2).call(); |
|
|
|
git.commit().setMessage("commit").call(); |
|
|
|
git.commit().setMessage("commit").call(); |
|
|
|
|
|
|
|
|
|
|
|
dc = db.readDirCache(); |
|
|
|
dc = db.readDirCache(); |
|
|
|
entry = dc.getEntry(path); |
|
|
|
entry = dc.getEntry(path); |
|
|
|
|
|
|
|
|
|
|
|
long sideLastMode = entry.getLastModified(); |
|
|
|
long sideLastMode = entry.getLastModified(); |
|
|
|
|
|
|
|
|
|
|
|
Thread.sleep(2000); |
|
|
|
Thread.sleep(2000); |
|
|
|
|
|
|
|
|
|
|
|
writeTrashFile(path, "uncommitted content"); |
|
|
|
writeTrashFile(path, "uncommitted content"); |
|
|
|
git.checkout().setName("master").call(); |
|
|
|
git.checkout().setName("master").call(); |
|
|
|
|
|
|
|
|
|
|
|
dc = db.readDirCache(); |
|
|
|
dc = db.readDirCache(); |
|
|
|
entry = dc.getEntry(path); |
|
|
|
entry = dc.getEntry(path); |
|
|
|
|
|
|
|
|
|
|
|
assertTrue("shall have equal mod time!", masterLastMod == sideLastMode); |
|
|
|
|
|
|
|
assertTrue("shall not equal master timestamp!", |
|
|
|
|
|
|
|
entry.getLastModified() == masterLastMod); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertTrue("shall have equal mod time!", masterLastMod == sideLastMode); |
|
|
|
|
|
|
|
assertTrue("shall not equal master timestamp!", |
|
|
|
|
|
|
|
entry.getLastModified() == masterLastMod); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|