Because the _allFieldsCache attribute gets inherited, when it gets set for a class, all subclasses will also see that list rather than their own, potentially different list. To fix this, use a global dict indexing on the metadata class instead.
It appears that Python doesn't reliably (or maybe just doesn't at all) flush and close non-standard FDs on exit. This randomly caused the artefacts list to get lost to /dev/null.
For example, if the HEAD is excluded:
warning: ref 'refs/heads/master' is excluded by the rev-list options
warning: ref 'HEAD' is excluded by the rev-list options
fatal: Refusing to create empty bundle.
The fatal message always appears last (though that's of course undocumented).
This verifies that all objects from the current clone are in either the dependency bundles or the current bundle. This guarantees that the repo as it has been clone at the time of retrieval can be reconstructed exactly from the bundles.
As a side-effect, if a non-standard Git server were to include objects in a clone pack that are not discoverable from refs, this will fail any attempt to archive such a clone. This could in the future be resolved by adding custom refs for those extra objects.
This also fixes a bug where prior bundles could be included as a dependency even though they contain no relevant data due to their refs (as refs are always listed in the bundle metadata). Instead, dependency detection now operates directly on commit and tag objects, which can only be present in one bundle.
stdin, stdout, and stderr being closed does not necessarily imply that the process has exited, although it usually does. Still need to explicitly wait for it to terminate after the I/O loop. This matches what the stdlib `subprocess.Popen._communicate` does as well.