Subject: Re: [PATCH 03/10] builtin: use default hash when outside a repository

From: Patrick Steinhardt <[email-masked]>
Date: Wed, 2 Jul 2025 17:08:17 +0200

On Tue, Jul 01, 2025 at 09:14:57PM +0000, brian m. carlson wrote:
> On 2025-07-01 at 11:35:33, Patrick Steinhardt wrote:
> > On Fri, Jun 20, 2025 at 01:19:35AM +0000, brian m. carlson wrote:
> > > We have some commands that can operate inside or outside a repository.
> > > If we're operating outside a repository, we clearly cannot use the
> > > repository's hash algorithm as a default since it doesn't exist, so
> > > instead, let's pick the default instead of specifically SHA-1.  Right
> > > now this results in no functional change since the default is SHA-1, but
> > > that may change in the future.
> > 
> > With the preceding commit in mind that introduced GIT_HASH_ORIGINAL you
> > could also argue that those callsites should be converted to use that
> > define instead. We always used to treat them as SHA1 repositories, and
> > we have no better way of telling otherwise, so we use the historical
> > value of SHA1 so that scripts aren't dependent on how exactly Git was
> > built.
> 
> I don't think I want to do that.  A lot of the functionality people use
> outside of repositories, such as index-pack and ls-remote, actually
> operates on repository objects and so it makes sense to use the default.
> 
> For instance, it will be a major inconvenience to still have to specify
> a custom object format three to five years after the switchover.

True. Initially it will be a pain for those edge cases, but the longer
the new default is in place the more useful it will become.

Patrick