[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] NPE when calling RepositoryCache.FileKey.isGitRepository on a relative path

On Wed, Jun 26, 2019 at 11:21 PM Dmitry Pavlenko <pavlenko@xxxxxxxxxxxxx> wrote:
Hello,
I can reproduce the NPE with a single line:

 RepositoryCache.FileKey.isGitRepository(new File("repo.git"), FS.DETECTED)

if the relative path "repo.git" doesn't exist yet.

It's a regression, the previous (File-based, not Path-based) JGit versions
worked fine in this situation.

The problem happens because

 new File("repo.git").toPath().getParent()

evaluates to null in

 FS.FileStoreAttributeCache.getFsTimestampResolution()

(The corresponding line is:Â Path dir = Files.isDirectory(file) ? file :
file.getParent();Â )

The documentation doesn't mention whether the path can or cannot be
relative.

So I wonder whether this is expected behaviour, and I should use the
absolute path or is it a bug in JGit and it should work with relative paths
as well?

I added a test with your example but it doesn't fail on Mac:
https://git.eclipse.org/r/#/c/144960/Â

Can you try that in your environment?

-Matthias