git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 12 of 21 in “Add a generated list of hooks in hook-list.h”
  1. 0/3 Add a generated list of hooks in hook-list.hÆvar Arnfjörð Bjarmason, Jun 17, 2021
  2. 1/3 hook.[ch]: move find_hook() to this new libraryÆvar Arnfjörð Bjarmason, Jun 17, 2021
  3. 2/3 hook.c: add a hook_exists() wrapper and use it in bugreport.cÆvar Arnfjörð Bjarmason, Jun 17, 2021
  4. 3/3 hook-list.h: add a generated list of hooks, like config-list.hÆvar Arnfjörð Bjarmason, Jun 17, 2021
  5. SZEDER GáborJun 18, 2021
  6. Eric SunshineJun 18, 2021
  7. Junio C HamanoJun 19, 2021
  8. Ævar Arnfjörð BjarmasonJun 20, 2021
  9. René ScharfeJun 20, 2021
  10. Johannes SchindelinJun 22, 2021
  11. Junio C HamanoJun 29, 2021
  12. René ScharfeJun 29, 2021
  13. 0/3 Add a generated list of hooks in hook-list.hÆvar Arnfjörð Bjarmason, Jun 29, 2021
  14. 1/3 hook.[ch]: move find_hook() to this new libraryÆvar Arnfjörð Bjarmason, Jun 29, 2021
  15. 3/3 hook-list.h: add a generated list of hooks, like config-list.hÆvar Arnfjörð Bjarmason, Jun 29, 2021
  16. René ScharfeJun 29, 2021
  17. Ævar Arnfjörð BjarmasonJun 29, 2021
  18. Emily ShafferJul 9, 2021
  19. Ævar Arnfjörð BjarmasonJul 10, 2021
  20. Emily ShafferJul 12, 2021
  21. 2/3 hook.c: add a hook_exists() wrapper and use it in bugreport.cÆvar Arnfjörð Bjarmason, Jun 29, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.