Re: [PATCH 3/3] hook-list.h: add a generated list of hooks, like config-list.h
- From
René Scharfe <l.s.r@web.de>
- Date
- Jun 29, 2021, 17:53 UTC
- Message-ID
- <20b1bfb6-8881-2a21-1753-0e2e508a7861@web.de>
- In-Reply-To
- <xmqqv95x4ijd.fsf@gitster.g>
Am 29.06.21 um 02:32 schrieb Junio C Hamano:
Show 21 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>> On Sun, 20 Jun 2021, René Scharfe wrote:
>>
>>> How about something like this?
>>>
>>> sed -n '/^~~~~*$/ {x; p;}; x' Documentation/githooks.txt |
>>> sort |
>>> sed 's/^.*$/ "&",/'
>>>
>>> sed is already used by generate-configlist.sh.
>>
>> I do like me a good sed script.
>>
>> Thanks,
>> Dscho
>
> Yup.
>
> This is buried below the 27-patch series, so the whole thing cannot
> advance until this gets sorted out.If it helps: You can add the patch below as number 28 or squash it in.
--- >8 --- Subject: [PATCH] generate-hooklist.sh: use sed instead of Perl
Allow hooklist.h to be built without Perl by finding, sorting and formatting hook names using two short sed(1) scripts and sort(1).
Signed-off-by: René Scharfe <l.s.r@web.de> --- generate-hooklist.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/generate-hooklist.sh b/generate-hooklist.sh index 5a3f7f849c..6f3de0a2ec 100755 --- a/generate-hooklist.sh +++ b/generate-hooklist.sh @@ -6,14 +6,9 @@ print_hook_list () { cat <<EOF static const char *hook_name_list[] = { EOF - perl -ne ' - chomp; - @l[$.] = $_; - push @h => $l[$. - 1] if /^~~~+$/s; - END { - print qq[\t"$_",\n] for sort @h; - } - ' <Documentation/githooks.txt + sed -n '/^~~~~*$/ {x; p;}; x' Documentation/githooks.txt | + sort | + sed 's/^.*$/ "&",/' cat <<EOF NULL, }; -- 2.32.0