Re: [PATCH 3/3] hook-list.h: add a generated list of hooks, like config-list.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 18.06.21 um 19:05 schrieb SZEDER Gábor:
> On Thu, Jun 17, 2021 at 12:09:36PM +0200, Ævar Arnfjörð Bjarmason wrote:
>> diff --git a/generate-hooklist.sh b/generate-hooklist.sh
>> new file mode 100755
>> index 0000000000..5a3f7f849c
>> --- /dev/null
>> +++ b/generate-hooklist.sh
>> @@ -0,0 +1,24 @@
>> +#!/bin/sh
>> +
>> +echo "/* Automatically generated by generate-hooklist.sh */"
>> +
>> +print_hook_list () {
>> +	cat <<EOF
>> +static const char *hook_name_list[] = {
>> +EOF
>> +	perl -ne '
>
> Why Perl?
>
> At the moment I can run 'make' and get a functioning git even when
> Perl is not installed.  With this patch that wouldn't work anymore.
>
> Both 'generate-cmdlist.sh' and 'generate-configlist.sh' can process
> the documentation into a header file with a long list in it without
> resorting to Perl; I'm sure that hooks could be processed without Perl
> as well.
>
>> +		chomp;
>> +		@l[$.] = $_;
>> +		push @h => $l[$. - 1] if /^~~~+$/s;
>> +		END {
>> +			print qq[\t"$_",\n] for sort @h;
>> +		}
>> +	' <Documentation/githooks.txt

How about something like this?

	sed -n '/^~~~~*$/ {x; p;}; x' Documentation/githooks.txt |
	sort |
	sed 's/^.*$/	"&",/'

sed is already used by generate-configlist.sh.

>> +	cat <<EOF
>> +	NULL,
>> +};
>> +EOF
>> +}
>> +
>> +echo
>> +print_hook_list





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux