Re: [PATCH 09/10] hook: show config scope in git hook list
- From
Adrian Ratiu <adrian.ratiu@collabora.com>
- Date
- Mar 10, 2026, 14:45 UTC
- Message-ID
- <878qbzg2ve.fsf@collabora.com>
- In-Reply-To
- <xmqqpl5c3brr.fsf@gitster.g>
On Mon, 09 Mar 2026, Junio C Hamano <gitster@pobox.com> wrote:
Show 28 quoted lines
> Adrian Ratiu <adrian.ratiu@collabora.com> writes:
>
>> +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?Yes, out of all the logic in this series, these printf's are the ones I'm most unsure about.
I'll try to come up with something better for machine parsing in v2.
Suggestions are very much welcome btw. :)