René Scharfe <l.s.r@xxxxxx> writes: >>> To me, this behaviour looks as >>> >>> Show the preceding line that contains the function name of >>> the match, unless the _PREVIOUS_ matching line is a function >>> name itself. > > To me it looks like: > > Show the preceding line that contains the function name of > the match. > > ("Show" meaning "show once", not "show for each match again and again".) > > Or: > > Show the preceding line that contains the function name of > the match, unless it is already shown for a different > reason, e.g. as a match or as the function line of a > previous match. Wow, that was a mouthful, but matches my understanding. I naïvely thought "when showing a hit, we may add the line that matches the function header pattern before the hit even that header line does not hit the grep pattern. But if the header line does hit the grep pattern, we do not bother show the same thing twice." was a reasonable goal to have. > 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. > >> Or I am totally confused? > > No, I think the documentation is wrong. I'd simply remove the part > after the comma, but there are probably better options. Documentation may not match the behaviour, but do we know what the behaviour we want is? To me, the last example that shows the same line twice (one as a real hit, the other because of "-p") looks a bit counter-intuitive for the purpose of "help me locate where the grep hits are". I dunno.