Subject: Re: [PATCH 09/10] hook: show config scope in git hook list

From: Adrian Ratiu <[email-masked]>
Date: Tue, 10 Mar 2026 16:45:09 +0200

On Mon, 09 Mar 2026, Junio C Hamano <[email-masked]> wrote:
> Adrian Ratiu <[email-masked]> 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. :)