// wait to ensure that file-modTimes and therefore index entry modTime
// doesn't match the modtime of index-file after next persistance
- modTimes.add(valueOf(fsTick(lastFile)));
+ fsTick(b);
// now add both files to the index. No racy git expected
- resetIndex(new FileTreeIteratorWithTimeControl(db, modTimes));
+ resetIndex(new FileTreeIterator(db));
assertEquals(
- "[a, mode:100644, time:t0, length:1, content:a]" +
- "[b, mode:100644, time:t0, length:1, content:b]",
+ "[a, mode:100644, time:t0, length:1, content:a]"
+ + "[b, mode:100644, time:t0, length:1, content:b]",
indexState(SMUDGE | MOD_TIME | LENGTH | CONTENT));
- // Remember the last modTime of index file. All modifications times of
- // further modification are translated to this value so it looks that
- // files have been modified in the same time slot as the index file
- modTimes.add(Long.valueOf(db.getIndexFile().lastModified()));
+ // wait to ensure the file 'a' is updated at t1.
+ fsTick(db.getIndexFile());
- // modify one file
- addToWorkDir("a", "a2");
- // now update the index the index. 'a' has to be racily clean -- because
- // it's modification time is exactly the same as the previous index file
- // mod time.
- resetIndex(new FileTreeIteratorWithTimeControl(db, modTimes));
+ // Create a racy git situation. This is a situation that the index is
+ // updated and then a file is modified within the same tick of the
+ // filesystem timestamp resolution. By changing the index file
+ // artificially, we create a fake racy situation.
+ File updatedA = writeToWorkDir("a", "a2");
+ long newLastModified = updatedA.lastModified() + 100;
+ assertTrue(updatedA.setLastModified(newLastModified));
+ resetIndex(new FileTreeIterator(db));
+ assertTrue(db.getIndexFile().setLastModified(newLastModified));
- db.readDirCache();
- // although racily clean a should not be reported as being dirty
+ DirCache dc = db.readDirCache();
+ // check index state: although racily clean a should not be reported as
+ // being dirty since we forcefully reset the index to match the working
+ // tree
assertEquals(
- "[a, mode:100644, time:t1, smudged, length:0, content:a2]" +
- "[b, mode:100644, time:t0, length:1, content:b]",
- indexState(SMUDGE|MOD_TIME|LENGTH|CONTENT));
+ "[a, mode:100644, time:t1, smudged, length:0, content:a2]"
+ + "[b, mode:100644, time:t0, length:1, content:b]",
+ indexState(SMUDGE | MOD_TIME | LENGTH | CONTENT));
+
+ // compare state of files in working tree with index to check that
+ // FileTreeIterator.isModified() works as expected
+ FileTreeIterator f = new FileTreeIterator(db.getWorkTree(), db.getFS(),
+ db.getConfig().get(WorkingTreeOptions.KEY));
+ assertTrue(f.findFile("a"));
+ try (ObjectReader reader = db.newObjectReader()) {
+ assertFalse(f.isModified(dc.getEntry("a"), false, reader));
+ }
}
- private File addToWorkDir(String path, String content) throws IOException {
+ private File writeToWorkDir(String path, String content) throws IOException {
File f = new File(db.getWorkTree(), path);
- FileOutputStream fos = new FileOutputStream(f);
- try {
+ try (FileOutputStream fos = new FileOutputStream(f)) {
fos.write(content.getBytes(Constants.CHARACTER_ENCODING));
return f;
- } finally {
- fos.close();
}
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jgit" version="2">
- <resource path="META-INF/MANIFEST.MF">
- <filter id="924844039">
- <resource path="src/org/eclipse/jgit/diff/DiffEntry.java" type="org.eclipse.jgit.diff.DiffEntry">
- <filter id="336658481">
-- <message_arguments>
- <message_argument value="5.0.4"/>
- <message_argument value="5.0.0"/>
- <message_argument value="org.eclipse.jgit.diff.DiffEntry"/>
- <message_argument value="diffAttribute"/>
-- </message_arguments>
-- </filter>
-- </resource>
<resource path="src/org/eclipse/jgit/errors/PackInvalidException.java" type="org.eclipse.jgit.errors.PackInvalidException">
<filter id="1142947843">
<message_arguments>
</message_arguments>
</filter>
</resource>
- <resource path="src/org/eclipse/jgit/lib/ConfigConstants.java" type="org.eclipse.jgit.lib.ConfigConstants">
- <filter id="336658481">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.lib.ConfigConstants"/>
- <message_argument value="CONFIG_KEY_REQUIRED"/>
- </message_arguments>
- </filter>
- <filter id="336658481">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.lib.ConfigConstants"/>
- <message_argument value="CONFIG_SECTION_LFS"/>
- </message_arguments>
- </filter>
- </resource>
+ <resource path="src/org/eclipse/jgit/lib/Constants.java" type="org.eclipse.jgit.lib.Constants">
+ <filter id="1141899266">
+ <message_arguments>
+ <message_argument value="4.7"/>
- <message_argument value="4.11"/>
++ <message_argument value="5.0"/>
+ <message_argument value="LOCK_SUFFIX"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/jgit/lib/GitmoduleEntry.java" type="org.eclipse.jgit.lib.GitmoduleEntry">
<filter id="1109393411">
<message_arguments>
</message_arguments>
</filter>
</resource>
- <resource path="src/org/eclipse/jgit/merge/ResolveMerger.java" type="org.eclipse.jgit.merge.ResolveMerger">
- <filter id="336658481">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.merge.ResolveMerger"/>
- <message_argument value="workingTreeOptions"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/storage/pack/PackStatistics.java" type="org.eclipse.jgit.storage.pack.PackStatistics$Accumulator">
- <filter id="336658481">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.storage.pack.PackStatistics.Accumulator"/>
- <message_argument value="advertised"/>
- </message_arguments>
- </filter>
- <filter id="336658481">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.storage.pack.PackStatistics.Accumulator"/>
- <message_argument value="haves"/>
- </message_arguments>
- </filter>
- <filter id="336658481">
++ <resource path="src/org/eclipse/jgit/lib/ObjectIdSerializer.java" type="org.eclipse.jgit.lib.ObjectIdSerializer">
++ <filter id="1141899266">
+ <message_arguments>
- <message_argument value="org.eclipse.jgit.storage.pack.PackStatistics.Accumulator"/>
- <message_argument value="timeNegotiating"/>
++ <message_argument value="4.11"/>
++ <message_argument value="5.0"/>
++ <message_argument value="readWithoutMarker(InputStream)"/>
+ </message_arguments>
+ </filter>
- <filter id="336658481">
++ <filter id="1141899266">
+ <message_arguments>
- <message_argument value="org.eclipse.jgit.storage.pack.PackStatistics.Accumulator"/>
- <message_argument value="wants"/>
++ <message_argument value="4.11"/>
++ <message_argument value="5.0"/>
++ <message_argument value="writeWithoutMarker(OutputStream, AnyObjectId)"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/jgit/util/FS.java" type="org.eclipse.jgit.util.FS">
<filter id="1141899266">
<message_arguments>