mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
cfe853e66b
Make githooks(5) the source of truth for what hooks git supports, and punt out early on hooks we don't know about in find_hook(). This ensures that the documentation and the C code's idea about existing hooks doesn't diverge. We still have Perl and Python code running its own hooks, but that'll be addressed by Emily Shaffer's upcoming "git hook run" command. This resolves a long-standing TODO item in bugreport.c of there being no centralized listing of hooks, and fixes a bug with the bugreport listing only knowing about 1/4 of the p4 hooks. It didn't know about the recent "reference-transaction" hook either. We could make the find_hook() function die() or BUG() out if the new known_hook() returned 0, but let's make it return NULL just as it does when it can't find a hook of a known type. Making it die() is overly anal, and unlikely to be what we need in catching stupid typos in the name of some new hook hardcoded in git.git's sources. By making this be tolerant of unknown hook names, changes in a later series to make "git hook run" run arbitrary user-configured hook names will be easier to implement. I have not been able to directly test the CMake change being made here. Since4c2c38e800
(ci: modification of main.yml to use cmake for vs-build job, 2020-06-26) some of the Windows CI has a hard dependency on CMake, this change works there, and is to my eyes an obviously correct use of a pattern established in previous CMake changes, namely: -061c2240b1
(Introduce CMake support for configuring Git, 2020-06-12) -709df95b78
(help: move list_config_help to builtin/help, 2020-04-16) -976aaedca0
(msvc: add a Makefile target to pre-generate the Visual Studio solution, 2019-07-29) The LC_ALL=C is needed because at least in my locale the dash ("-") is ignored for the purposes of sorting, which results in a different order. I'm not aware of anything in git that has a hard dependency on the order, but e.g. the bugreport output would end up using whatever locale was in effect when git was compiled. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Helped-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 lines
299 B
Bash
Executable file
20 lines
299 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Usage: ./generate-hooklist.sh >hook-list.h
|
|
|
|
cat <<EOF
|
|
/* Automatically generated by generate-hooklist.sh */
|
|
|
|
static const char *hook_name_list[] = {
|
|
EOF
|
|
|
|
sed -n \
|
|
-e '/^~~~~*$/ {x; s/^.*$/ "&",/; p;}' \
|
|
-e 'x' \
|
|
<Documentation/githooks.txt |
|
|
LC_ALL=C sort
|
|
|
|
cat <<EOF
|
|
NULL,
|
|
};
|
|
EOF
|