mbox series

[v3,00/17] use config-based hooks (config-based hooks part II)

Message ID 20201222000435.1529768-1-emilyshaffer@google.com (mailing list archive)
Headers show
Series use config-based hooks (config-based hooks part II) | expand

Message

Emily Shaffer Dec. 22, 2020, 12:04 a.m. UTC
Since v2:
 - Renamed 'master' to 'main' in new t5411 (proc-receive) test.
 - Removed some accidentally included debug strings.
 - Fixed a nasty bug in the reference-transaction hook conversion where calling
   'oid_to_hex()' would invalidate references to the output of earlier
   'oid_to_hex()' runs farther up the callstack. Instead, the hook callsite now
   uses 'oid_to_hex_r()'.

Another thing I wanted to do in this series but ended up not having time
for before the holidays was to figure out a way to consolidate
Documentation/githooks.txt and Documentation/git-hook.txt. My personal
preference would be to remove githooks.txt's contents, move the "Hooks"
header from there into git-hook.txt, and have 'git help githooks'/'git
help hooks' redirect to git-hook.txt; I don't have a patch to share here
because I ran out of time before vacation :) What do others envision the
documentation looking like?

Thanks!
 - Emily

CI run: https://github.com/nasamuffin/git/actions/runs/436905873

Emily Shaffer (17):
  commit: use config-based hooks
  am: convert applypatch hooks to use config
  merge: use config-based hooks for post-merge hook
  gc: use hook library for pre-auto-gc hook
  rebase: teach pre-rebase to use hook.h
  read-cache: convert post-index-change hook to use config
  receive-pack: convert push-to-checkout hook to hook.h
  git-p4: use 'git hook' to run hooks
  hooks: convert 'post-checkout' hook to hook library
  hook: convert 'post-rewrite' hook to config
  transport: convert pre-push hook to use config
  reference-transaction: look for hooks in config
  receive-pack: convert 'update' hook to hook.h
  proc-receive: acquire hook list from hook.h
  post-update: use hook.h library
  receive-pack: convert receive hooks to hook.h
  run-command: stop thinking about hooks

 Documentation/githooks.txt                    |  45 +++
 builtin/am.c                                  |  30 +-
 builtin/checkout.c                            |  16 +-
 builtin/clone.c                               |   7 +-
 builtin/commit.c                              |  11 +-
 builtin/gc.c                                  |   4 +-
 builtin/merge.c                               |  14 +-
 builtin/rebase.c                              |   7 +-
 builtin/receive-pack.c                        | 326 ++++++++++--------
 builtin/worktree.c                            |  30 +-
 commit.c                                      |  20 +-
 commit.h                                      |   3 +-
 git-p4.py                                     |  67 +---
 hook.c                                        |  39 ++-
 read-cache.c                                  |  12 +-
 refs.c                                        |  38 +-
 reset.c                                       |  15 +-
 run-command.c                                 |  66 ----
 run-command.h                                 |  24 --
 sequencer.c                                   |  83 ++---
 t/t1416-ref-transaction-hooks.sh              |  12 +-
 t/t5411/test-0015-too-many-hooks-error.sh     |  47 +++
 ...3-pre-commit-and-pre-merge-commit-hooks.sh |  17 +-
 transport.c                                   |  55 +--
 24 files changed, 493 insertions(+), 495 deletions(-)
 create mode 100644 t/t5411/test-0015-too-many-hooks-error.sh

Comments

Emily Shaffer Dec. 28, 2020, 7:59 p.m. UTC | #1
On Mon, Dec 21, 2020 at 04:04:18PM -0800, Emily Shaffer wrote:
> 
> Another thing I wanted to do in this series but ended up not having time
> for before the holidays was to figure out a way to consolidate
> Documentation/githooks.txt and Documentation/git-hook.txt. My personal
> preference would be to remove githooks.txt's contents, move the "Hooks"
> header from there into git-hook.txt, and have 'git help githooks'/'git
> help hooks' redirect to git-hook.txt; I don't have a patch to share here
> because I ran out of time before vacation :) What do others envision the
> documentation looking like?

I could use some tips on this, actually. I don't see anywhere that we
make one document redirect to another, or else I don't know what to look
for. If I replace the contents of `githooks.txt` with
`include::git-hook.txt[]`, `generate-cmdlist.sh` chokes because there is
no name to grep for in `githooks.txt`. Is there a documented example of
a manpage redirecting to a different manpage?

 - Emily
Emily Shaffer Dec. 28, 2020, 11:15 p.m. UTC | #2
On Mon, Dec 28, 2020 at 02:40:15PM -0800, Emily Shaffer wrote:
> 
> By showing the list of all hooks in 'git help hook' for users to refer
> to, 'git help hook' becomes a one-stop shop for hook authorship. Since
> some may still have muscle memory for 'git help githooks', though,
> reference the 'git hook' commands and otherwise don't remove content.
> 
> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> ---
> 
> Sorry for the wonky subject. It seemed unnecessary to send the entirety
> of the topic again when there were no changes. (I was able to push this
> patch to my fork without -f, so indeed the rest is unchanged.)
> 
> I'd really prefer if 'git help githooks' opens the 'git-hook.txt' manpage,
> but I couldn't figure out how to do that. This seemed like the next best thing
> to me - users can still find information at the old manpage, but get a little
> nudge towards the new manpage in case they didn't notice it.
> 
> Extremely open to other notes about the direction of these docs; I'm not
> confident in anything except that it'd be annoying to have 'git help
> githooks' remain unchanged.

Even now, this is missing the native-hooks.txt from the commit. Ugh.
This commit breaks the build; please do not add it to the topic. I will
include a fixed version with the next reroll. Sorry.

That said, the intent is clear enough for me to still feel comfortable
inviting review.

 - Emily
Josh Steadmon Feb. 18, 2021, 10:32 p.m. UTC | #3
On 2020.12.21 16:04, Emily Shaffer wrote:
> Since v2:
>  - Renamed 'master' to 'main' in new t5411 (proc-receive) test.
>  - Removed some accidentally included debug strings.
>  - Fixed a nasty bug in the reference-transaction hook conversion where calling
>    'oid_to_hex()' would invalidate references to the output of earlier
>    'oid_to_hex()' runs farther up the callstack. Instead, the hook callsite now
>    uses 'oid_to_hex_r()'.
> 
> Another thing I wanted to do in this series but ended up not having time
> for before the holidays was to figure out a way to consolidate
> Documentation/githooks.txt and Documentation/git-hook.txt. My personal
> preference would be to remove githooks.txt's contents, move the "Hooks"
> header from there into git-hook.txt, and have 'git help githooks'/'git
> help hooks' redirect to git-hook.txt; I don't have a patch to share here
> because I ran out of time before vacation :) What do others envision the
> documentation looking like?
> 
> Thanks!
>  - Emily
> 
> CI run: https://github.com/nasamuffin/git/actions/runs/436905873
> 
> Emily Shaffer (17):
>   commit: use config-based hooks
>   am: convert applypatch hooks to use config
>   merge: use config-based hooks for post-merge hook
>   gc: use hook library for pre-auto-gc hook
>   rebase: teach pre-rebase to use hook.h
>   read-cache: convert post-index-change hook to use config
>   receive-pack: convert push-to-checkout hook to hook.h
>   git-p4: use 'git hook' to run hooks
>   hooks: convert 'post-checkout' hook to hook library
>   hook: convert 'post-rewrite' hook to config
>   transport: convert pre-push hook to use config
>   reference-transaction: look for hooks in config
>   receive-pack: convert 'update' hook to hook.h
>   proc-receive: acquire hook list from hook.h
>   post-update: use hook.h library
>   receive-pack: convert receive hooks to hook.h
>   run-command: stop thinking about hooks
> 
>  Documentation/githooks.txt                    |  45 +++
>  builtin/am.c                                  |  30 +-
>  builtin/checkout.c                            |  16 +-
>  builtin/clone.c                               |   7 +-
>  builtin/commit.c                              |  11 +-
>  builtin/gc.c                                  |   4 +-
>  builtin/merge.c                               |  14 +-
>  builtin/rebase.c                              |   7 +-
>  builtin/receive-pack.c                        | 326 ++++++++++--------
>  builtin/worktree.c                            |  30 +-
>  commit.c                                      |  20 +-
>  commit.h                                      |   3 +-
>  git-p4.py                                     |  67 +---
>  hook.c                                        |  39 ++-
>  read-cache.c                                  |  12 +-
>  refs.c                                        |  38 +-
>  reset.c                                       |  15 +-
>  run-command.c                                 |  66 ----
>  run-command.h                                 |  24 --
>  sequencer.c                                   |  83 ++---
>  t/t1416-ref-transaction-hooks.sh              |  12 +-
>  t/t5411/test-0015-too-many-hooks-error.sh     |  47 +++
>  ...3-pre-commit-and-pre-merge-commit-hooks.sh |  17 +-
>  transport.c                                   |  55 +--
>  24 files changed, 493 insertions(+), 495 deletions(-)
>  create mode 100644 t/t5411/test-0015-too-many-hooks-error.sh
> 
> -- 
> 2.28.0.rc0.142.g3c755180ce-goog
> 

My only complaints on the previous version of this series have now been
resolved, so LGTM.

Reviewed-by: Josh Steadmon <steadmon@google.com>