summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@google.com>2019-07-09 14:49:30 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-07-09 15:33:23 +0200
commit84e6c24e58f9d5dbbeef9fd299e5c5598e7a48e7 (patch)
tree0004dd8ed651377dd9177134756e75cbd2e21cee /org.eclipse.jgit.test
parent850b9d7540025a974870bc75a2412ee91469a198 (diff)
downloadjgit-84e6c24e58f9d5dbbeef9fd299e5c5598e7a48e7.tar.gz
jgit-84e6c24e58f9d5dbbeef9fd299e5c5598e7a48e7.zip
FileSnapshot#equals: consider UNKNOWN_SIZE
Add a unittest. In commit I5485db55 ("Fix FileSnapshot's consideration of file size"), the special casing of UNKNOWN_SIZE was forgotten. This change, together with I493f3b57b ("Measure file timestamp resolution used in FileSnapshot") introduced a regression that would occasionally surface in Gerrit integration tests marked UseLocalDisk, with the symptom that creating the Admin user in NoteDb failed with a LOCK_FAILURE. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: I7ffd972581f815c144f810481103c7985af5feb0
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java
index 5ebdeb6e8f..6e458fbbf0 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java
@@ -180,6 +180,17 @@ public class FileSnapshotTest {
assertTrue(save.wasSizeChanged());
}
+ @Test
+ public void fileSnapshotEquals() throws Exception {
+ // 0 sized FileSnapshot.
+ FileSnapshot fs1 = FileSnapshot.MISSING_FILE;
+ // UNKNOWN_SIZE FileSnapshot.
+ FileSnapshot fs2 = FileSnapshot.save(fs1.lastModified());
+
+ assertTrue(fs1.equals(fs2));
+ assertTrue(fs2.equals(fs1));
+ }
+
private File createFile(String string) throws IOException {
trash.mkdirs();
File f = File.createTempFile(string, "tdat", trash);