git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Zach Riggle <zachriggle@gmail.com>
To: git@vger.kernel.org
Subject: git grep --show-function treats GOTO labels as function names
Date: Wed, 27 May 2020 17:29:08 -0500	[thread overview]
Message-ID: <CAMP9c5k=Ci8eQyOdzW7a-sssgp9g9TJ+rxAAPF3YLDCr7t6wrg@mail.gmail.com> (raw)

Git grep is an amazing tool, and --show-function makes it very easy to
create reports that contain not only line information, but the
containing function as well.

It looks like there is an issue with how the parser handles "goto"
labels, as it treats them the same as a function name.

In the example below, there is only one function, with two matches,
but using --show-function indicates there are two function names.

$ cat test2.cpp
int main() {
    FOO
exit:
    FOO
}

$ git --version
git version 2.26.2

$ git grep --no-index --show-function -e FOO test2.cpp
test2.cpp=1=int main() {
test2.cpp:2:    FOO
test2.cpp=3=exit:
test2.cpp:4:    FOO


Zach Riggle

             reply	other threads:[~2020-05-27 22:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 22:29 Zach Riggle [this message]
2020-05-27 22:48 ` git grep --show-function treats GOTO labels as function names Jeff King
2020-05-27 22:54   ` Zach Riggle
2020-05-27 23:04     ` Zach Riggle
2020-05-27 23:05       ` Zach Riggle
2020-05-27 23:16       ` Jeff King
2020-05-28 19:01         ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMP9c5k=Ci8eQyOdzW7a-sssgp9g9TJ+rxAAPF3YLDCr7t6wrg@mail.gmail.com' \
    --to=zachriggle@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).