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

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


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

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

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?
Dmitry Pavlenko,
TMate Software,
http://subgit.com/ - git-svn bridge