Re: [PATCH 1/1] git-grep: improve the --show-function behaviour
- From
- Oleg Nesterov <oleg@redhat.com>
- Date
- Sep 13, 2023, 10:15 UTC
- Message-ID
- <20230913101501.GC535@redhat.com>
- In-Reply-To
- <df05f761-c498-6930-bfd8-265f7e23d8ee@web.de>
On 09/12, René Scharfe wrote:
Show 13 quoted lines
> > >> 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.
Show 14 quoted lines
> > 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.