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

[RFC PATCH v2 0/2] MVP implementation of remote-suggested hooks

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Jul 16, 2021, 17:57 UTC
Message-ID
<cover.1626453569.git.jonathantanmy@google.com>
In-Reply-To
<cover.1623881977.git.jonathantanmy@google.com>

Here's an updated version of the remote-suggested hooks RFC, hopefully addressing some of the concerns people have brought up (e.g. auto-updating without letting the user verify, or prompting about hooks by default). It consists of two main parts:

 - Non-interactive prompts during certain Git commands about the
   existence of hooks. These prompts are turned *off* by default.
 - New "git hook" subcommands that can install these hooks (so that the
   aforementioned Git prompts or out-of-band installation instructions
   can tell users to install these hooks in a platform-independent way).
   These subcommands work whether or not prompts are enabled.
You can see how they work in patch 2's t1361.

In doing this, I have tried to scope down the overall effort as much as possible (to avoid security risks as much as possible, among other things), concentrating on situations that server-side hooks cannot handle. I think the main thing is that server-side hooks can check and prompt upon push, but they cannot catch problems that the client could have noticed upon commit; if the end user pushes a commit chain and only notices problems then, the user would have to redo the commits (possibly through an interactive rebase on the spot). Catching problems upon commit would prevent this problem, only necessitating amending the commit.

In the Gerrit use case, Gerrit requires a specific "Change-Id" trailer in the commit message, but I can foresee the same issue in projects that require their commit messages to fit a certain template or projects that want lints to be run but their builds, for some reason, don't run arbitrary code (or they have no builds at all).

To that end, I have added a prompt for the "commit-msg" hook if the remote has suggested one, but there are none currently installed. (Similar prompts could be added for other commit-related hooks.) The other prompts are upon clone and upon fetch (if the hooks have been updated).

Jonathan Tan (2):
  hook: move list of hooks
  hook: remote-suggested hooks
 builtin/bugreport.c               |  38 +-----
 builtin/clone.c                   |  12 ++
 builtin/fetch.c                   |  17 +++
 builtin/hook.c                    |  17 ++-
 hook.c                            | 185 +++++++++++++++++++++++++++++-
 hook.h                            |   6 +
 t/t1361-remote-suggested-hooks.sh | 105 +++++++++++++++++
 7 files changed, 340 insertions(+), 40 deletions(-)
 create mode 100755 t/t1361-remote-suggested-hooks.sh
-- 
2.32.0.402.g57bb445576-goog
Previous: Junio C HamanoNext: Jonathan Tan
Message 22 of 36 in “MVP implementation of remote-suggested hooks”
  1. 0/2 MVP implementation of remote-suggested hooksJonathan Tan, Jun 16, 2021
  2. 1/2 hook: move list of hooksJonathan Tan, Jun 16, 2021
  3. Emily ShafferJun 18, 2021
  4. Jonathan TanJun 18, 2021
  5. 2/2 clone,fetch: remote-suggested auto-updating hooksJonathan Tan, Jun 16, 2021
  6. Emily ShafferJun 18, 2021
  7. Junio C HamanoJun 17, 2021
  8. Jonathan TanJun 18, 2021
  9. Emily ShafferJun 18, 2021
  10. Jonathan TanJun 18, 2021
  11. Randall S. BeckerJun 18, 2021
  12. Matt RogersJun 19, 2021
  13. Jonathan TanJun 21, 2021
  14. Ævar Arnfjörð BjarmasonJun 20, 2021
  15. Jonathan TanJun 21, 2021
  16. Ævar Arnfjörð BjarmasonJun 21, 2021
  17. Jonathan TanJun 22, 2021
  18. brian m. carlsonJun 22, 2021
  19. Jonathan TanJun 23, 2021
  20. brian m. carlsonJun 24, 2021
  21. Junio C HamanoJun 28, 2021
  22. 0/2 MVP implementation of remote-suggested hooksJonathan Tan, Jul 16, 2021
  23. 1/2 hook: move list of hooksJonathan Tan, Jul 16, 2021
  24. 2/2 hook: remote-suggested hooksJonathan Tan, Jul 16, 2021
  25. Junio C HamanoJul 19, 2021
  26. Jonathan TanJul 20, 2021
  27. Phil HordJul 20, 2021
  28. Jonathan TanJul 20, 2021
  29. Ævar Arnfjörð BjarmasonJul 20, 2021
  30. Jonathan TanJul 20, 2021
  31. Emily ShafferJul 27, 2021
  32. Junio C HamanoJul 27, 2021
  33. Jonathan TanJul 27, 2021
  34. Junio C HamanoJul 27, 2021
  35. Junio C HamanoJul 19, 2021
  36. Jonathan TanJul 20, 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.