Browse Source

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 <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.1
Michael Keppler 5 years ago committed by Matthias Sohn
parent
commit
6cb21049d7
  1. 12
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java

12
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java vendored

@ -671,8 +671,7 @@ public class DirCache {
// Write the individual file entries. // Write the individual file entries.
final int smudge_s; Instant smudge;
final int smudge_ns;
if (myLock != null) { if (myLock != null) {
// For new files we need to smudge the index entry // For new files we need to smudge the index entry
// if they have been modified "now". Ideally we'd // if they have been modified "now". Ideally we'd
@ -680,12 +679,10 @@ public class DirCache {
// so we use the current timestamp as a approximation. // so we use the current timestamp as a approximation.
myLock.createCommitSnapshot(); myLock.createCommitSnapshot();
snapshot = myLock.getCommitSnapshot(); snapshot = myLock.getCommitSnapshot();
smudge_s = (int) (snapshot.lastModifiedInstant().getEpochSecond()); smudge = snapshot.lastModifiedInstant();
smudge_ns = snapshot.lastModifiedInstant().getNano();
} else { } else {
// Used in unit tests only // Used in unit tests only
smudge_ns = 0; smudge = Instant.EPOCH;
smudge_s = 0;
} }
// Check if tree is non-null here since calling updateSmudgedEntries // Check if tree is non-null here since calling updateSmudgedEntries
@ -697,8 +694,9 @@ public class DirCache {
for (int i = 0; i < entryCnt; i++) { for (int i = 0; i < entryCnt; i++) {
final DirCacheEntry e = sortedEntries[i]; final DirCacheEntry e = sortedEntries[i];
if (e.mightBeRacilyClean(smudge_s, smudge_ns)) if (e.mightBeRacilyClean(smudge)) {
e.smudgeRacilyClean(); e.smudgeRacilyClean();
}
e.write(dos); e.write(dos);
} }

Loading…
Cancel
Save