From 6cb21049d7a48dbc4384fe98a3d3093eb457e381 Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Tue, 20 Aug 2019 16:09:12 +0200 Subject: [PATCH] Fix deprecation in DirCache caused by Instant based DirCacheEntry Replace the two int variables smudge_s and smudge_ns by an Instant and use the new method DirCacheEntry.mightBeRacilyClean(Instant). Change-Id: Id70adbb0856a64909617acf65da1bae8e2ae934a Signed-off-by: Michael Keppler Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/dircache/DirCache.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 0cfd16b58..a778de910 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java @@ -671,8 +671,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 @@ -680,12 +679,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 @@ -697,8 +694,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); }