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

Re: [PATCH v2 00/13] hook.[ch]: new library to run hooks + simple hook conversion

From
Emily Shaffer <emilyshaffer@google.com>
Date
Oct 15, 2021, 16:23 UTC
Message-ID
<YWmrAuUeO38Tf/W+@google.com>
In-Reply-To
<cover-v2-00.13-00000000000-20211015T093918Z-avarab@gmail.com>
On Tue, Oct 12, 2021 at 03:30:25PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 47 quoted lines
> 
> This series is part 2 of an incremental restart of the greater
> "config-based hooks" topic by Emily Shaffer that I've been helping
> with. See [1] for part 1, and [2] (search for "mark2") for a summary
> of parts to come.
> 
> This goes on top of the "ab/config-based-hooks-1" topic that's already
> in "next" and marked for graduation to "master".
> 
> In this topic we build upon the skeleton hook.[ch] library and build
> infrastructure added in part 1 and add a hook running library and new
> "git hook" command.
> 
> The new "git hook" command is (for now) only for the benefit of
> in-tree non-C programs that need to run hooks, and this series
> converts git-send-email and git-p4 to use it.
> 
> At the end of the series we remove
> "run_hook_{le,ve}()" from run-command.c, as we've migrated all its
> callers.
> 
> What we don't do is convert any of the more complex in-tree hooks that
> require input on stdin such as "pre-receive" and the like, that's in
> later parts once this lands.
> 
> This series is approximately patch 6-20/36 of the previous 36 patch
> ab/config-based-hooks-base topic. A range-diff to that v5[3] is
> included below.
> 
> The changes since that v5 are rather trivial, they are:
> 
>  * Formatting changes to reduce the diff to parts that come after this
>    (which Emily & I were juggling at the time), and re-flowing some
>    overly long lines.
> 
>  * The new test is now marked for SANITIZE=leak testing, with the new
>    test facility I've added recently (and which just landed in
>    "master"). They all pass, the new API doesn't leak.
> 
>  * I rewrote some of the git-send-email.perl code to avoid
>    de-duplication and hardcoding (just using intermediate variables).
> 
> Things to focus on reviewing:
> 
>  * This should all be pretty solid and well tested, but the git-p4.py
>    part in particular I've never tested for real (not having access to
>    p4), and think Emily hasn't either[4].

Correct. I seem to remember wanting to give this a test and not having access to real perforce to try it against.

Show 15 quoted lines
> 
>    The relevant patch looks trivially correct to me[5], and I've tried it
>    out in the Python REPL. But if any of the CC'd people active in
>    git-p4.py development could give it some end-to-end testing that
>    would be much appreciated.
> 
>  * Both Python and Perl code now calls the in-between "git hook run"
>    command rather than calling hooks directly. Will this behave
>    differently due to any special behavior running via a git built-in
>    adds?
> 
>    I vaguely recall a third-party "git-foo" program breaking in the
>    past when invoked as "git foo" but not "git-foo", due to git
>    squatting on SIGINT, but none of that should be relevant here
>    (we're not starting a pager etc.).

I would be very surprised, assuming that we invoke 'git hook' in the same way that those Python and Perl scripts invoke other 'git whatever' commands...

That said, once we invoke a user hook, all bets are off as far as "we're not starting a pager or anything". A determined user could find a reason to invoke a pager, editor, whatever during a hook. I'm curious to know more about this remembered breakage.

Last time I looked at the range-diff; this time I'll look at the individual patches, instead.

Note: I looked at a bunch of these offline, so sorry for the sudden
ingress of mails today ;)
 - Emily
Previous: Emily ShafferNext: Junio C Hamano
Message 29 of 115 in “hook.[ch]: new library to run hooks + simple hook conversion”
  1. 00/13 hook.[ch]: new library to run hooks + simple hook conversionÆvar Arnfjörð Bjarmason, Oct 15, 2021
  2. 01/13 hook: add 'run' subcommandÆvar Arnfjörð Bjarmason, Oct 15, 2021
  3. Emily ShafferOct 15, 2021
  4. Eric SunshineOct 15, 2021
  5. Ævar Arnfjörð BjarmasonOct 19, 2021
  6. 02/13 gc: use hook library for pre-auto-gc hookÆvar Arnfjörð Bjarmason, Oct 15, 2021
  7. Emily ShafferOct 15, 2021
  8. 04/13 am: convert applypatch to use hook.hÆvar Arnfjörð Bjarmason, Oct 15, 2021
  9. Emily ShafferOct 15, 2021
  10. 05/13 hooks: convert 'post-checkout' hook to hook libraryÆvar Arnfjörð Bjarmason, Oct 15, 2021
  11. Emily ShafferOct 15, 2021
  12. 03/13 rebase: convert pre-rebase to use hook.hÆvar Arnfjörð Bjarmason, Oct 15, 2021
  13. Emily ShafferOct 15, 2021
  14. 06/13 merge: convert post-merge to use hook.hÆvar Arnfjörð Bjarmason, Oct 15, 2021
  15. Emily ShafferOct 15, 2021
  16. 07/13 git hook run: add an --ignore-missing flagÆvar Arnfjörð Bjarmason, Oct 15, 2021
  17. Emily ShafferOct 15, 2021
  18. 08/13 send-email: use 'git hook run' for 'sendemail-validate'Ævar Arnfjörð Bjarmason, Oct 15, 2021
  19. Emily ShafferOct 15, 2021
  20. 09/13 git-p4: use 'git hook' to run hooksÆvar Arnfjörð Bjarmason, Oct 15, 2021
  21. Emily ShafferOct 15, 2021
  22. 10/13 commit: convert {pre-commit,prepare-commit-msg} hook to hook.hÆvar Arnfjörð Bjarmason, Oct 15, 2021
  23. Emily ShafferOct 15, 2021
  24. 11/13 read-cache: convert post-index-change to use hook.hÆvar Arnfjörð Bjarmason, Oct 15, 2021
  25. Emily ShafferOct 15, 2021
  26. 12/13 receive-pack: convert push-to-checkout hook to hook.hÆvar Arnfjörð Bjarmason, Oct 15, 2021
  27. 13/13 run-command: remove old run_hook_{le,ve}() hook APIÆvar Arnfjörð Bjarmason, Oct 15, 2021
  28. Emily ShafferOct 15, 2021
  29. Emily ShafferOct 15, 2021
  30. Junio C HamanoOct 16, 2021
  31. Eric SunshineOct 16, 2021
  32. Ævar Arnfjörð BjarmasonOct 16, 2021
  33. Junio C HamanoOct 16, 2021
  34. Ævar Arnfjörð BjarmasonOct 16, 2021
  35. 00/13 hook.[ch]: new library to run hooks + simple hook conversionÆvar Arnfjörð Bjarmason, Oct 19, 2021
  36. 01/13 hook: add 'run' subcommandÆvar Arnfjörð Bjarmason, Oct 19, 2021
  37. 02/13 gc: use hook library for pre-auto-gc hookÆvar Arnfjörð Bjarmason, Oct 19, 2021
  38. 03/13 rebase: convert pre-rebase to use hook.hÆvar Arnfjörð Bjarmason, Oct 19, 2021
  39. Junio C HamanoOct 29, 2021
  40. 04/13 am: convert applypatch to use hook.hÆvar Arnfjörð Bjarmason, Oct 19, 2021
  41. 05/13 hooks: convert 'post-checkout' hook to hook libraryÆvar Arnfjörð Bjarmason, Oct 19, 2021
  42. Junio C HamanoOct 29, 2021
  43. 06/13 merge: convert post-merge to use hook.hÆvar Arnfjörð Bjarmason, Oct 19, 2021
  44. 07/13 git hook run: add an --ignore-missing flagÆvar Arnfjörð Bjarmason, Oct 19, 2021
  45. Junio C HamanoOct 29, 2021
  46. 08/13 send-email: use 'git hook run' for 'sendemail-validate'Ævar Arnfjörð Bjarmason, Oct 19, 2021
  47. 09/13 git-p4: use 'git hook' to run hooksÆvar Arnfjörð Bjarmason, Oct 19, 2021
  48. 10/13 commit: convert {pre-commit,prepare-commit-msg} hook to hook.hÆvar Arnfjörð Bjarmason, Oct 19, 2021
  49. 11/13 read-cache: convert post-index-change to use hook.hÆvar Arnfjörð Bjarmason, Oct 19, 2021
  50. 12/13 receive-pack: convert push-to-checkout hook to hook.hÆvar Arnfjörð Bjarmason, Oct 19, 2021
  51. 13/13 run-command: remove old run_hook_{le,ve}() hook APIÆvar Arnfjörð Bjarmason, Oct 19, 2021
  52. Junio C HamanoOct 29, 2021
  53. 00/17 hook.[ch]: new library to run hooks + simple hook conversionÆvar Arnfjörð Bjarmason, Nov 1, 2021
  54. 02/17 hook API: add a run_hooks() wrapperÆvar Arnfjörð Bjarmason, Nov 1, 2021
  55. 09/17 hooks: convert non-worktree 'post-checkout' hook to hook libraryÆvar Arnfjörð Bjarmason, Nov 1, 2021
  56. 01/17 hook: add 'run' subcommandÆvar Arnfjörð Bjarmason, Nov 1, 2021
  57. 05/17 hook API: add a run_hooks_l() wrapperÆvar Arnfjörð Bjarmason, Nov 1, 2021
  58. 04/17 am: convert {pre,post}-applypatch to use hook.hÆvar Arnfjörð Bjarmason, Nov 1, 2021
  59. 03/17 gc: use hook library for pre-auto-gc hookÆvar Arnfjörð Bjarmason, Nov 1, 2021
  60. 07/17 am: convert applypatch-msg to use hook.hÆvar Arnfjörð Bjarmason, Nov 1, 2021
  61. 06/17 rebase: convert pre-rebase to use hook.hÆvar Arnfjörð Bjarmason, Nov 1, 2021
  62. 10/17 hooks: convert worktree 'post-checkout' hook to hook libraryÆvar Arnfjörð Bjarmason, Nov 1, 2021
  63. 08/17 merge: convert post-merge to use hook.hÆvar Arnfjörð Bjarmason, Nov 1, 2021
  64. 14/17 commit: convert {pre-commit,prepare-commit-msg} hook to hook.hÆvar Arnfjörð Bjarmason, Nov 1, 2021
  65. 17/17 run-command: remove old run_hook_{le,ve}() hook APIÆvar Arnfjörð Bjarmason, Nov 1, 2021
  66. 13/17 git-p4: use 'git hook' to run hooksÆvar Arnfjörð Bjarmason, Nov 1, 2021
  67. 15/17 read-cache: convert post-index-change to use hook.hÆvar Arnfjörð Bjarmason, Nov 1, 2021
  68. 16/17 receive-pack: convert push-to-checkout hook to hook.hÆvar Arnfjörð Bjarmason, Nov 1, 2021
  69. 12/17 send-email: use 'git hook run' for 'sendemail-validate'Ævar Arnfjörð Bjarmason, Nov 1, 2021
  70. 11/17 git hook run: add an --ignore-missing flagÆvar Arnfjörð Bjarmason, Nov 1, 2021
  71. 00/17 hook.[ch]: new library to run hooks + simple hook conversionÆvar Arnfjörð Bjarmason, Nov 23, 2021
  72. 01/17 hook: add 'run' subcommandÆvar Arnfjörð Bjarmason, Nov 23, 2021
  73. 02/17 hook API: add a run_hooks() wrapperÆvar Arnfjörð Bjarmason, Nov 23, 2021
  74. 03/17 gc: use hook library for pre-auto-gc hookÆvar Arnfjörð Bjarmason, Nov 23, 2021
  75. 06/17 rebase: convert pre-rebase to use hook.hÆvar Arnfjörð Bjarmason, Nov 23, 2021
  76. 04/17 am: convert {pre,post}-applypatch to use hook.hÆvar Arnfjörð Bjarmason, Nov 23, 2021
  77. 05/17 hook API: add a run_hooks_l() wrapperÆvar Arnfjörð Bjarmason, Nov 23, 2021
  78. 08/17 merge: convert post-merge to use hook.hÆvar Arnfjörð Bjarmason, Nov 23, 2021
  79. 07/17 am: convert applypatch-msg to use hook.hÆvar Arnfjörð Bjarmason, Nov 23, 2021
  80. 10/17 hooks: convert worktree 'post-checkout' hook to hook libraryÆvar Arnfjörð Bjarmason, Nov 23, 2021
  81. 14/17 commit: convert {pre-commit,prepare-commit-msg} hook to hook.hÆvar Arnfjörð Bjarmason, Nov 23, 2021
  82. 13/17 git-p4: use 'git hook' to run hooksÆvar Arnfjörð Bjarmason, Nov 23, 2021
  83. 15/17 read-cache: convert post-index-change to use hook.hÆvar Arnfjörð Bjarmason, Nov 23, 2021
  84. 16/17 receive-pack: convert push-to-checkout hook to hook.hÆvar Arnfjörð Bjarmason, Nov 23, 2021
  85. 17/17 run-command: remove old run_hook_{le,ve}() hook APIÆvar Arnfjörð Bjarmason, Nov 23, 2021
  86. 12/17 send-email: use 'git hook run' for 'sendemail-validate'Ævar Arnfjörð Bjarmason, Nov 23, 2021
  87. 11/17 git hook run: add an --ignore-missing flagÆvar Arnfjörð Bjarmason, Nov 23, 2021
  88. 09/17 hooks: convert non-worktree 'post-checkout' hook to hook libraryÆvar Arnfjörð Bjarmason, Nov 23, 2021
  89. 00/17 hook.[ch]: new library to run hooks + simple hook conversionÆvar Arnfjörð Bjarmason, Dec 22, 2021
  90. 01/17 hook: add 'run' subcommandÆvar Arnfjörð Bjarmason, Dec 22, 2021
  91. Emily ShafferJan 7, 2022
  92. Junio C HamanoJan 7, 2022
  93. 03/17 gc: use hook library for pre-auto-gc hookÆvar Arnfjörð Bjarmason, Dec 22, 2021
  94. 04/17 am: convert {pre,post}-applypatch to use hook.hÆvar Arnfjörð Bjarmason, Dec 22, 2021
  95. 06/17 rebase: convert pre-rebase to use hook.hÆvar Arnfjörð Bjarmason, Dec 22, 2021
  96. 05/17 hook API: add a run_hooks_l() wrapperÆvar Arnfjörð Bjarmason, Dec 22, 2021
  97. Glen ChooJan 6, 2022
  98. Emily ShafferJan 7, 2022
  99. 02/17 hook API: add a run_hooks() wrapperÆvar Arnfjörð Bjarmason, Dec 22, 2021
  100. Glen ChooJan 6, 2022
  101. 07/17 am: convert applypatch-msg to use hook.hÆvar Arnfjörð Bjarmason, Dec 22, 2021
  102. 10/17 hooks: convert worktree 'post-checkout' hook to hook libraryÆvar Arnfjörð Bjarmason, Dec 22, 2021
  103. 09/17 hooks: convert non-worktree 'post-checkout' hook to hook libraryÆvar Arnfjörð Bjarmason, Dec 22, 2021
  104. 08/17 merge: convert post-merge to use hook.hÆvar Arnfjörð Bjarmason, Dec 22, 2021
  105. 11/17 git hook run: add an --ignore-missing flagÆvar Arnfjörð Bjarmason, Dec 22, 2021
  106. Glen ChooJan 6, 2022
  107. 12/17 send-email: use 'git hook run' for 'sendemail-validate'Ævar Arnfjörð Bjarmason, Dec 22, 2021
  108. 13/17 git-p4: use 'git hook' to run hooksÆvar Arnfjörð Bjarmason, Dec 22, 2021
  109. 14/17 commit: convert {pre-commit,prepare-commit-msg} hook to hook.hÆvar Arnfjörð Bjarmason, Dec 22, 2021
  110. 15/17 read-cache: convert post-index-change to use hook.hÆvar Arnfjörð Bjarmason, Dec 22, 2021
  111. 16/17 receive-pack: convert push-to-checkout hook to hook.hÆvar Arnfjörð Bjarmason, Dec 22, 2021
  112. 17/17 run-command: remove old run_hook_{le,ve}() hook APIÆvar Arnfjörð Bjarmason, Dec 22, 2021
  113. Glen ChooJan 6, 2022
  114. Emily ShafferJan 7, 2022
  115. Emily ShafferJan 7, 2022

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.