Re: git clone of empty repositories doesn't preserve hash
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Apr 5, 2023, 22:48 UTC
- Message-ID
- <ZC36xXGBIAHcetZW@tapette.crustytoothpaste.net>
- In-Reply-To
- <xmqq355euj2i.fsf@gitster.g>
On 2023-04-05 at 21:15:33, Junio C Hamano wrote:
Show 12 quoted lines
> A user could prepare an empty repository and set it to use SHA256 as > the object format. The new repository created by "git clone" from > such a repository however would not record that it is expecting > objects in the same SHA256 format. This works as expected if the > source repository is not empty. > > Just like we started copying the name of the primary branch from the > remote repository even if it is unborn in 3d8314f8 (clone: propagate > empty remote HEAD even with other branches, 2022-07-07), lift the > code that records the object format out of the block executed only > when cloning from an instantiated repository, so that it works also > when cloning from an empty repository.
Yeah, this looks like the right thing to do. I know this did work originally, at least for protocol v2, but I may have neglected to add a test when I wrote it and it regressed. Thanks for the patch, which I think is obviously correct, and adding a test for this case.
-- brian m. carlson (he/him or they/them) Toronto, Ontario, CA