path: root/builtin
diff options
authorRené Scharfe <>2011-06-05 15:24:36 (GMT)
committerJunio C Hamano <>2011-06-06 01:15:27 (GMT)
commit1d84f72ef1dee1f851e11a6d92e8ab3f1979b2a2 (patch)
treea84d8f3a9ee7118fd2ec26dc1c5c9041541187e3 /builtin
parenta8f0e7649eba3ce78e1f09fc4dcbb2c3fcc3d866 (diff)
grep: add --heading
With --heading, the filename is printed once before matches from that file instead of at the start of each line, giving more screen space to the actual search results. This option is taken from ack ( And now git grep can dress up like it: $ git config alias.ack "grep --break --heading --line-number" $ git ack -e --heading Documentation/git-grep.txt 154:--heading:: t/ 785:test_expect_success 'grep --heading' ' 786: git grep --heading -e char -e lo_w hello.c hello_world >actual && 808: git grep --break --heading -n --color \ Signed-off-by: Rene Scharfe <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin')
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 42bb87f..cccf8da 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -824,6 +824,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
OPT__COLOR(&opt.color, "highlight matches"),
OPT_BOOLEAN(0, "break", &opt.file_break,
"print empty line between matches from different files"),
+ OPT_BOOLEAN(0, "heading", &opt.heading,
+ "show filename only once above matches from same file"),
OPT_CALLBACK('C', NULL, &opt, "n",
"show <n> context lines before and after matches",