Clone git repository in-memory

Viewed 1846

I've been trying to clone a tiny git configuration repository into memory using JGIT and JIMFS using something like

FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path gitPath = Files.createDirectories(fs.getPath("/git")); 
Git.cloneRepository().setURI(...).setBranch(...).setDirectory(gitPath.toFile())
                    .setCredentialsProvider(...).call()

But since JIMFS works with the path Path API (since it doesn't use the default Filesystem), while JGIT uses the File API, JIMFS doesn't implement to toFile() call:

@Override
public File toFile() {
    // documented as unsupported for anything but the default file system
    throw new UnsupportedOperationException();
}

So I get is this UnsupportedOperationException. Is there a simple way of getting this (or a similar) setup to work without resorting to a temp directory on the disk?

2 Answers
Related