Subject: Re: [PATCH] show-index: warn when falling back to SHA-1 outside a repository

From: Patrick Steinhardt <[email-masked]>
Date: Fri, 30 Jan 2026 14:40:15 +0100

On Fri, Jan 30, 2026 at 02:34:53PM +0530, Shreyansh Paliwal wrote:
> > On 2026-01-29 at 15:36:55, Shreyansh Paliwal wrote:
> > >	/*
> > >	 * Fallback to SHA1 if we are running outside of a repository.
> > >	 *
> > > -	 * TODO: Figure out and implement a way to detect the hash algorithm in use by the
> > > -	 *       the index file passed in and use that instead.
> > > +	 * TODO: If a future implementation of index file version encodes the hash
> > > +	 *       algorithm in its header, enable show-index to infer it from the
> > > +	 *       header rather than relying on repository context or a default fallback.
> > >	 */
> > > -	if (!the_hash_algo)
> > > +	if (!the_hash_algo) {
> > > +		warning(_("assuming SHA-1; use --object-format to override"));
> > >		repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
> > 
> > If we're going to start producing a warning, can we also learn a
> > `--quiet` option to silence it?
> 
> Hi,
> 
> That is a good point.
> However, the warning is only shown for a particular usecase: when 
> 'git show-index' is run outside of a repository and --object-format
> is not specified. Given that narrow scope, I’m wondering whether
> adding a dedicated --quiet option for only this warning would be worthwhile.
> 
> Let me know what you think :)

I also wonder whether "--quiet" might be a bit _too_ generic in this
context. I would rather want to use this flag for something that you
actually have a good reason to silence, instead of only for a warning.

In theory, the user already has the ability to silence the warning: they
can simply pass "--object-format=sha256". If you think that's not enough
I'd buid on top of our `advice_if_enabled()` infra, so that the warning
can be globally disabled by setting a config option.

Thanks!

Patrick