Re: [PATCH 6/9] rev-parse: allow printing compatibility hash
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 19, 2025, 23:24 UTC
- Message-ID
- <xmqqikheyqil.fsf@gitster.g>
- In-Reply-To
- <20250919010911.649831-7-sandals@crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 10 quoted lines
> Right now, we have a way to print the storage hash, the input hash, and > the output hash, but we lack a way to print the compatibility hash. Add > a new type to --show-object-format, compat, which prints this value. > > If no compatibility hash exists, simply print a newline. This is > important to allow users to use multiple options at once while still > getting unambiguous output. > > Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> > ---
Nice.
At first I somehow thought
$ git rev-parse --show-object-format=compat HEAD
in a SHA-1 primary repository would give the equivalent object name for the commit at HEAD in SHA-256 world, but that is expecting too much out of a simple 50-line patch ;-).
Show 20 quoted lines
>
> if (strcmp(val, "storage") &&
> + strcmp(val, "compat") &&
> strcmp(val, "input") &&
> strcmp(val, "output"))
> die(_("unknown mode for --show-object-format: %s"),
> arg);
> - puts(the_hash_algo->name);
> +
> + if (!strcmp(val, "compat")) {
> + if (the_repository->compat_hash_algo)
> + puts(the_repository->compat_hash_algo->name);
> + else
> + putchar('\n');
> + } else {
> + puts(the_hash_algo->name);
> + }
> continue;
> }
> if (!strcmp(arg, "--show-ref-format")) {Pretty straight-forward.
Thanks.