summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2011-06-05 15:24:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-06-06 01:15:26 (GMT)
commita8f0e7649eba3ce78e1f09fc4dcbb2c3fcc3d866 (patch)
tree5076f16de30d3761802d5dfa241054662fb5b8c7 /builtin/grep.c
parent08303c3636ef750bfafd1c47f363120cb439b367 (diff)
downloadgit-a8f0e7649eba3ce78e1f09fc4dcbb2c3fcc3d866.zip
git-a8f0e7649eba3ce78e1f09fc4dcbb2c3fcc3d866.tar.gz
git-a8f0e7649eba3ce78e1f09fc4dcbb2c3fcc3d866.tar.bz2
grep: add --break
With --break, an empty line is printed between matches from different files, increasing readability. This option is taken from ack (http://betterthangrep.com/). Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 0d5a90b..42bb87f 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -822,6 +822,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
OPT_BOOLEAN('c', "count", &opt.count,
"show the number of matches instead of matching lines"),
OPT__COLOR(&opt.color, "highlight matches"),
+ OPT_BOOLEAN(0, "break", &opt.file_break,
+ "print empty line between matches from different files"),
OPT_GROUP(""),
OPT_CALLBACK('C', NULL, &opt, "n",
"show <n> context lines before and after matches",
@@ -976,7 +978,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
use_threads = 0;
if (use_threads) {
- if (opt.pre_context || opt.post_context)
+ if (opt.pre_context || opt.post_context || opt.file_break)
skip_first_line = 1;
start_threads(&opt);
}