Re: [RFC/PATCH] diff: simplify cpp funcname regex
- From
Jeff King <peff@peff.net>
- Date
- Mar 18, 2014, 05:24 UTC
- Message-ID
- <20140318052456.GA17454@sigill.intra.peff.net>
- In-Reply-To
- <5322A82E.9060808@viscovery.net>
On Fri, Mar 14, 2014 at 07:56:46AM +0100, Johannes Sixt wrote:
Show 12 quoted lines
> Consider this code:
>
> void above()
> {}
> static int Y;
> static int A;
> int bar()
> {
> return X;
> }
> void below()
> {}Thanks, this example is very helpful.
Show 8 quoted lines
> When you 'git grep --function-context X', then you get this output with
> the current pattern, you proposal, and my proposal (file name etc omitted
> for brevity):
>
> int bar()
> {
> return X;
> }Right, that makes sense to me.
Show 15 quoted lines
> When you 'git grep --function-context Y', what do you want to see? With
> the current pattern, and with your pattern that forbids semicolon we get:
>
> void above()
> {}
> static int Y;
> static int A;
>
> and with my simple pattern, which allows semicolon, we get merely
>
> static int Y;
>
> because the line itself is a hunk header (and we do not look back any
> further) and the next line is as well. That is not exactly "function
> context", and that is what I'm a bit worried about.Hmm. To be honest, I do not see yours as all that bad. Is "above()" or "A" actually interesting here? I'm not sure that they are. But then I do not use --function-context myself.
I guess it violates the "show things that are vaguely nearby, rather than a container" view of context that we discussed earlier. But somehow that seems less important to me with "--function-context".
So I dunno. I kind of like your version.
-Peff