Browse Source

Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution

Bug: 548682
Change-Id: I48840d3a68cf1db92c056d218a0d5ed0b9ea4c45
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.1
Matthias Sohn 5 years ago
parent
commit
79ede0c322
  1. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java
  2. 1
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

8
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.errors.CommandFailedException;
import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.lib.RepositoryCache;
import org.junit.After; import org.junit.After;
import org.junit.Assume; import org.junit.Assume;
import org.junit.Before; 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));
}
} }

1
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$ + System.getProperty("java.vm.version") + '|'; //$NON-NLS-1$
private static Duration getFsTimestampResolution(Path file) { private static Duration getFsTimestampResolution(Path file) {
file = file.toAbsolutePath();
Path dir = Files.isDirectory(file) ? file : file.getParent(); Path dir = Files.isDirectory(file) ? file : file.getParent();
FileStore s; FileStore s;
try { try {

Loading…
Cancel
Save