Subject: Re: [PATCH 1/1] git-grep: improve the --show-function behaviour

From: Oleg Nesterov <[email-masked]>
Date: Wed, 13 Sep 2023 12:15:01 +0200

On 09/12, René Scharfe wrote:
>
> >> So perhaps git-grep needs another change, something like
> >>
> >> 	if (match_funcname(opt, gs, bol, end_of_line(...)))
> >> 		return;
> >>
> >> at the start of show_funcname_line(), but my patch does not change this
> >> behaviour.
>
> Yes, to make it match the documentation it would need something like
> that.  (Though I'd add a match_funcname() call before the
> show_funcname_line() call in grep_source_1() instead, as it already has
> the eol value.)

Yes, I too thought about this. Except I thought that it makes sense to
pass the additional "unsigned eol" argument to show_funcname_line().
But in any case show_pre_context() will need to calculate eol.

However this is just a minor detail, I am fine either way.

> > So, just in case, please see V2 below. In my opinion it _fixes_ the
> > current behaviour. With this patch
> >
> > 	$ ./git grep --untracked -pn func2 TEST1.c
> > 	TEST1.c:4:void func2()
>
> Indeed that matches the letter of the documentation.
>
> > 	$ ./git grep --untracked -pn xxx TEST2.c
> > 	TEST2.c:1:void func(xxx)
> > 	TEST2.c=1=void func(xxx)
> > 	TEST2.c:3:      use(xxx);
>
> That one as well.

So. Can I assume you agree with my patch ? ;)

> No, I think the documentation is wrong.

Well, to me it looks good, but only after this patch.

Oleg.