]> source.dussan.org Git - jgit.git/commitdiff
Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution 26/145126/13
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 26 Jun 2019 22:39:24 +0000 (00:39 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 17 Jul 2019 07:42:14 +0000 (09:42 +0200)
Bug: 548682
Change-Id: I48840d3a68cf1db92c056d218a0d5ed0b9ea4c45
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

index 59c8e31c0318dfaa32cba7bb1c67ea3d9b5e9c79..6b3d58bae7a437000ea89f5d189754320163e295 100644 (file)
@@ -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));
+       }
 }
index 67634cbe781af06fae25e0d169b3c1413ef3d767..a970a7df23adfae9800641431fc01edcb1f727ec 100644 (file)
@@ -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 {