Unable to use JGit to do some operations on a blobless clone that I can do via Git on the command line. Specifically unable to get the blobs later. For example, consider the following sequence of Git operations on the command line:
# Clone the repository but don't checkout any blobs
git clone --no-checkout --filter=blob:none <GIT-URL> .
# Checkout a branch that is *not* the main branch on the remote
git fetch origin develop:develop
# Move to the new branch
git symbolic-ref HEAD refs/heads/develop
git checkout develop <DIRECTORY-OR-FILE>
...
I'm using the following Java code to mimic the above:
FilterSpec filter = FilterSpec.fromFilterLine("blob:none");
try (Git git = Git.cloneRepository()
.setCredentialsProvider(getCredentialsProvider())
.setDirectory(new File("/tmp/repository"))
.setURI(<GIT-URL>)
.setRemote(Constants.DEFAULT_REMOTE_NAME)
.setTransportConfigCallback(t -> t.setFilterSpec(filter))
.setNoCheckout(true)
.call()) {
git.fetch()
.setCredentialsProvider(getCredentialsProvider())
.setRemote(Constants.DEFAULT_REMOTE_NAME)
.setRefSpecs("refs/heads/develop:refs/heads/develop")
.call();
git.getRepository()
.getRefDatabase()
.newUpdate(Constants.HEAD, false)
.link("refs/heads/develop");
git.checkout()
.setName("develop")
.addPath(<DIRECTORY-OR-FILE>)
.call();
...
}
The checkout call fails with messages like:
org.eclipse.jgit.errors.MissingObjectException: Missing unknown 57a7e7d782f72a1e846b08415c56684f8f42e5bf
The checkout also fails from the command line on the repository cloned via JGit.