From: Matthias Sohn Date: Tue, 10 Sep 2019 14:08:45 +0000 (+0200) Subject: Fix WorkingTreeIterator.compareMetadata() for CheckStat.MINIMAL X-Git-Tag: v5.5.0.201909110433-r~1^2^2^2^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=84ac86ee61989bab441904e3e72b2b98199cccfc;p=jgit.git Fix WorkingTreeIterator.compareMetadata() for CheckStat.MINIMAL If CheckStat is MINIMAL or timestamps have no nanosecond part WorkingTreeIterator.compareMetaData only checks the second part of timestamps and ignores nanoseconds which may have ended up in the index by using native git. If fileLastModified.getEpochSecond() == cacheLastModified.getEpochSecond() we currently proceed comparing fileLastModified and cacheLastModified with full precision which is wrong since we determined that we detected reduced timestamp resolution. Fix this and also handle smudged index entries for CheckStat.MINIMAL. Change-Id: I6149885903ac63d79b42d234cc02aa4e19578f3c Signed-off-by: Matthias Sohn --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java index 299f07fb09..a83165daa2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java @@ -950,9 +950,10 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator { if (fileLastModified.getEpochSecond() != cacheLastModified .getEpochSecond()) { return MetadataDiff.DIFFER_BY_TIMESTAMP; + } else if (entry.isSmudged()) { + return MetadataDiff.SMUDGED; } - } - if (!fileLastModified.equals(cacheLastModified)) { + } else if (!fileLastModified.equals(cacheLastModified)) { return MetadataDiff.DIFFER_BY_TIMESTAMP; } else if (entry.isSmudged()) { return MetadataDiff.SMUDGED;