git clone of empty repositories doesn't preserve hash
- From
Adam Majer <adamm@zombino.com>
- Date
- Apr 5, 2023, 10:28 UTC
- Message-ID
- <e7a8957e-6251-39f1-5109-87d4dd382e81@zombino.com>
Hi all,
I've noticed while adding support for sha256 repositories for Gitea that,
git init --bare --object-format=sha256 a git clone a b
Then the repository b is initialized as default hash, so sha1. It seems that receive-pack will list the null OID in the header if there are no refs available, but the upload-pack doesn't list anything and hence the header with capabilities and the hash function is missing
git receive-pack a git upload-pack a
What is the right approach here? Could upload-pack send a NULL OID followed by header info that is then used by clone?
There is a workaround to specify the hash via GIT_DEFAULT_HASH. Not ideal though.
Thanks, Adam