Re: [PATCH] show-index: warn when falling back to SHA-1 outside a repository
- From
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
- Date
- Jan 30, 2026, 09:04 UTC
- Message-ID
- <20260130090525.254665-1-shreyanshpaliwalcmsmn@gmail.com>
- In-Reply-To
- <aXvpSPpfvulKu57P@fruit.crustytoothpaste.net>
Show 17 quoted lines
> 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 :)
Best, Shreyansh