[RFC PATCH v2 0/2] configuration-based hook management (was: [TOPIC 2/17] Hooks in the future)
- From
Emily Shaffer <emilyshaffer@google.com>
- Date
- Apr 14, 2020, 00:54 UTC
- Message-ID
- <20200414005457.3505-1-emilyshaffer@google.com>
- In-Reply-To
- <20200413215256.GA18990@coredump.intra.peff.net>
Not much to look at compared to the original RFC I sent some months ago. This implements Peff's suggestion of using the "hookcmd" section as a layer of indirection. The scope is a little smaller than the original RFC as it doesn't have a way to remove hooks from downstream (yet), and ordering numbers are dropped (for now).
One thing that's missing, as evidenced by the TODO, is a way to handle arbitrary options given within a "hookcmd" unit. I think this can be achieved with a callback, since it seems plausible that "pre-receive" might want a different set of options than "post-commit" or so on. To me, it sounds achievable with a callback; I imagine a follow-on teaching git-hook how to remove a hook with something like "hookcmd.foo.skip = true" will give an OK indication of how that might look.
Overall though, I think this is simpler than the first version of the RFC because I was reminded by wiser folks than I to "keep it simple, stupid." ;)
I think it's feasible that with these couple patches applied, someone who wanted to jump in early could replace their .git/hook/whatever-hookname with some boilerplate like
xargs -n 1 'sh -c' <<<"$(git hook --list whatever-hookname)"
and give it a shot. Untested snippet. :)
CI run: https://github.com/gitgitgadget/git/pull/611/checks
- Emily
Emily Shaffer (2): hook: scaffolding for git-hook subcommand hook: add --list mode
.gitignore | 1 + Documentation/git-hook.txt | 53 ++++++++++++++++++++ Makefile | 2 + builtin.h | 1 + builtin/hook.c | 77 +++++++++++++++++++++++++++++ git.c | 1 + hook.c | 92 +++++++++++++++++++++++++++++++++++ hook.h | 13 +++++ t/t1360-config-based-hooks.sh | 58 ++++++++++++++++++++++ 9 files changed, 298 insertions(+) create mode 100644 Documentation/git-hook.txt create mode 100644 builtin/hook.c create mode 100644 hook.c create mode 100644 hook.h create mode 100755 t/t1360-config-based-hooks.sh
-- 2.26.0.110.g2183baf09c-goog