From 79ede0c3227b0c5f5d7790b58a0881486e06d7cc Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 27 Jun 2019 00:39:24 +0200 Subject: [PATCH] Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution Bug: 548682 Change-Id: I48840d3a68cf1db92c056d218a0d5ed0b9ea4c45 Signed-off-by: Matthias Sohn --- .../tst/org/eclipse/jgit/util/FSTest.java | 8 ++++++++ org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 1 + 2 files changed, 9 insertions(+) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java index 59c8e31c03..6b3d58bae7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java @@ -65,6 +65,7 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jgit.errors.CommandFailedException; import org.eclipse.jgit.junit.RepositoryTestCase; +import org.eclipse.jgit.lib.RepositoryCache; import org.junit.After; import org.junit.Assume; import org.junit.Before; @@ -223,4 +224,11 @@ public class FSTest { } } } + + // bug 548682 + @Test + public void testRepoCacheRelativePathUnbornRepo() { + assertFalse(RepositoryCache.FileKey + .isGitRepository(new File("repo.git"), FS.DETECTED)); + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index 67634cbe78..a970a7df23 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -218,6 +218,7 @@ public abstract class FS { + System.getProperty("java.vm.version") + '|'; //$NON-NLS-1$ private static Duration getFsTimestampResolution(Path file) { + file = file.toAbsolutePath(); Path dir = Files.isDirectory(file) ? file : file.getParent(); FileStore s; try { -- 2.39.5