Detect incomplete / corrupt repositories in cache
It's possible that if the Antora process is killed abruptly, it will leave behind incomplete and/or corrupt repositories in the cache. This renders the cache unusable. Antora should detect this situation and reclone the repository.
This scenario can be reproduced by running Antora, then immediately killing the process using Ctrl+C (or some other means of process killing) while its cloning repositories. The next invocation of Antora should fail with a message similar to this one:
error: Failed to read git object with oid <sha1> in <url> [ref: <refname>]
One solution to this problem is to add a lock file while Antora is cloning or fetching the repository (possibly interacting with it at all). Once Antora is done, it removes the lock file. Thus, the presence of the lock file at the start of the run indicates that the repository was not closed cleanly and shouldn't be reused.
Another change is to do more thorough validation on the repository to determine if it's good. Currently, Antora does a shallow lookup of the HEAD reference. It could go deeper and try to resolve the HEAD reference fully. It's not guaranteed to find a valid repo, but it would be more likely.
Making this change does highlight that fact that two instances of Antora cannot be run using the same cache folder. Each instance of Antora that runs in parallel needs to have its own cache so that there are no conflicts when writing to the git index (or reading while another process is writing). This point should be highlighted in the docs.