Re: [PATCH v4 3/9] hook: add list command
On Fri, Sep 11, 2020 at 02:27:42PM +0100, Phillip Wood wrote:
Show 23 quoted lines
>
> Hi Emily
>
> > +Global config
> > +----
> > + [hook "post-commit"]
> > + command = "linter"
> > + command = "~/typocheck.sh"
> > +
> > + [hookcmd "linter"]
> > + command = "/bin/linter --c"
> > +----
> > +
> > +Local config
> > +----
> > + [hook "prepare-commit-msg"]
> > + command = "linter"
> > + [hook "post-commit"]
> > + command = "python ~/run-test-suite.py"
> > +----
>
> I think it would be helpful to have a couple of lines explaining what the
> example configuration sets up
Show 13 quoted lines
>
> > +COMMANDS
> > +--------
> > +
> > +list <hook-name>::
> > +
> > +List the hooks which have been configured for <hook-name>. Hooks appear
> > +in the order they should be run, and note the config scope where the relevant
> > +`hook.<hook-name>.command` was specified, not the `hookcmd` (if applicable).
>
> Thanks for clarifying that it is the origin of the hook.<hook-name>.command
> that is printed. An example of the output of the config above would be
> useful I think.
Oh, that's a good idea - you're absolutely right. I'll do that.
Show 15 quoted lines
> > +/*
> > + * NEEDSWORK: a stateful hook_head means we can't run two hook events in the
> > + * background at the same time - which might be ok, or might not.
> > + *
> > + * Maybe it's better to cache a list head per hookname, since we can probably
> > + * guess that the hook list won't change during a user-initiated operation. For
> > + * now, within list_hooks, call clear_hook_list() at the outset.
> > + */
> > +static LIST_HEAD(hook_head);
>
> I can see a cache might be useful for the sequencer which needs to run the
> prepare-msg hook for each commit (it should probably not be running the
> post-commit hook but does at the moment) and for am which runs some hooks
> for each patch but until then I'm not sure why we need a global variable
> here, can't we just declare `hook_head` in `list_hook()`?
Yeah, I agree. I'll make that change with the next reroll.
Thanks for reading.
- Emily