Re: [RFC PATCH v2 0/2] configuration-based hook management
- From
Jeff King <peff@peff.net>
- Date
- Apr 14, 2020, 20:27 UTC
- Message-ID
- <20200414202738.GD1879688@coredump.intra.peff.net>
- In-Reply-To
- <20200414192418.GB5478@google.com>
On Tue, Apr 14, 2020 at 12:24:18PM -0700, Emily Shaffer wrote:
Show 14 quoted lines
> > 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.
> 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