diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java index 95e1d2143..f07c24efc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java @@ -657,8 +657,7 @@ void writeTo(File dir, OutputStream os) throws IOException { // Write the individual file entries. - final int smudge_s; - final int smudge_ns; + Instant smudge; if (myLock != null) { // For new files we need to smudge the index entry // if they have been modified "now". Ideally we'd @@ -666,12 +665,10 @@ void writeTo(File dir, OutputStream os) throws IOException { // so we use the current timestamp as a approximation. myLock.createCommitSnapshot(); snapshot = myLock.getCommitSnapshot(); - smudge_s = (int) (snapshot.lastModifiedInstant().getEpochSecond()); - smudge_ns = snapshot.lastModifiedInstant().getNano(); + smudge = snapshot.lastModifiedInstant(); } else { // Used in unit tests only - smudge_ns = 0; - smudge_s = 0; + smudge = Instant.EPOCH; } // Check if tree is non-null here since calling updateSmudgedEntries @@ -683,8 +680,9 @@ void writeTo(File dir, OutputStream os) throws IOException { for (int i = 0; i < entryCnt; i++) { final DirCacheEntry e = sortedEntries[i]; - if (e.mightBeRacilyClean(smudge_s, smudge_ns)) + if (e.mightBeRacilyClean(smudge)) { e.smudgeRacilyClean(); + } e.write(dos); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java index d4db15ce9..0e91f0d74 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java @@ -378,7 +378,7 @@ public final boolean mightBeRacilyClean(Instant smudge) { // final int base = infoOffset + P_MTIME; final int mtime = NB.decodeInt32(info, base); - if (smudge.getEpochSecond() == mtime) { + if ((int) smudge.getEpochSecond() == mtime) { return smudge.getNano() <= NB.decodeInt32(info, base + 4); } return false; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java index d432c9445..4f3eb05b1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java @@ -412,6 +412,9 @@ public long getLastModified() { return attributes.getLastModifiedInstant().toEpochMilli(); } + /** + * @since 5.1.9 + */ @Override public Instant getLastModifiedInstant() { return attributes.getLastModifiedInstant();