Re: [RFC PATCH v2 0/2] configuration-based hook management
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Apr 15, 2020, 10:01 UTC
- Message-ID
- <b4013e48-cd70-ddf1-8800-b239de9b56c3@gmail.com>
- In-Reply-To
- <20200414202738.GD1879688@coredump.intra.peff.net>
On 14/04/2020 21:27, Jeff King wrote:
Show 26 quoted lines
> On Tue, Apr 14, 2020 at 12:24:18PM -0700, Emily Shaffer wrote: > >>> Without the redirection one could have >>> hook.pre-commit.linter.command = my-command >>> hook.pre-commit.check-whitespace.command = 'git diff --check --cached' >> [...] >> We'd need to fudge one of these fields to include the extra section, I >> think. Unfortunate, because I find your example very tidy, but in >> practice maybe not very neat. The closest thing I can find to a nice way >> of writing it might be: >> >> [hook.pre-commit "linter"] >> command = my-command >> before = check-whitespace >> [hook.pre-commit "check-whitespace"] >> command = 'git diff --check --cached' > > Syntactically the whole section between the outer dots is the > subsection. So it's: > > [hook "pre-commit.check-whitespace"] > command = ... > > And I don't think we want to change the config syntax at this point. > Even in the neater dotted notation, we must keep that whole thing as a > subsection, because existing subsections may contain dots, too.
Thanks for clarifying that, I agree we don't want to change the config syntax and break existing subsections
Best Wishes
Phillip
Show 9 quoted lines
>> But this is kind of a lie; the sections aren't "hook", "pre-commit", and >> "linter" as you'd expect. Whether it's OK to lie like this, though, I >> don't know - I suspect it might make it awkward for others trying to >> parse the config. (my Vim syntax highlighter had kind of a hard time.) > > I think we should avoid it if possible. There are some subtleties there, > like the fact that subsections are case-sensitive, but sections and keys > are not.> -Peff >