Re: [PATCH 09/10] hook: show config scope in git hook list
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 9, 2026, 21:59 UTC
- Message-ID
- <xmqqpl5c3brr.fsf@gitster.g>
- In-Reply-To
- <20260309005416.2760030-10-adrian.ratiu@collabora.com>
Adrian Ratiu <adrian.ratiu@collabora.com> writes:
Show 16 quoted lines
> +list [-z] [--show-scope]::
> Print a list of hooks which will be run on `<hook-name>` event. If no
> hooks are configured for that event, print a warning and return 1.
> Use `-z` to terminate output lines with NUL instead of newlines.
> ...
> case HOOK_CONFIGURED:
> - printf("%s%c", h->u.configured.friendly_name, line_terminator);
> + if (show_scope)
> + printf("%s (%s)%c",
> + h->u.configured.friendly_name,
> + config_scope_name(h->u.configured.scope),
> + line_terminator);
> + else
> + printf("%s%c", h->u.configured.friendly_name,
> + line_terminator);
> break;Everything in this patch was as expected (the most important of which is where the data is kept, which is in the new structure hook_config_cache_entry that was introduced in the previous step for use case like this), except for the above bit.
I wonder if this already interacts well enough with "-z", or a minor tweak would make it better? Wouldn't a machine consumer expect that friendly name and cope be given as two separate and easily parseable fields in the same record?