summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorLibravatar René Scharfe <rene.scharfe@lsrfire.ath.cx>2011-06-05 17:24:25 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2011-06-05 18:15:26 -0700
commita8f0e7649eba3ce78e1f09fc4dcbb2c3fcc3d866 (patch)
tree5076f16de30d3761802d5dfa241054662fb5b8c7 /grep.c
parentgrep: fix coloring of hunk marks between files (diff)
downloadtgif-a8f0e7649eba3ce78e1f09fc4dcbb2c3fcc3d866.tar.xz
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 'grep.c')
-rw-r--r--grep.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index 3f15085d0e..b0b860a984 100644
--- a/grep.c
+++ b/grep.c
@@ -721,7 +721,10 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
int rest = eol - bol;
char *line_color = NULL;
- if (opt->pre_context || opt->post_context) {
+ if (opt->file_break && opt->last_shown == 0) {
+ if (opt->show_hunk_mark)
+ opt->output(opt, "\n", 1);
+ } else if (opt->pre_context || opt->post_context) {
if (opt->last_shown == 0) {
if (opt->show_hunk_mark) {
output_color(opt, "--", 2, opt->color_sep);
@@ -941,7 +944,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
if (!opt->output)
opt->output = std_output;
- if (opt->pre_context || opt->post_context) {
+ if (opt->pre_context || opt->post_context || opt->file_break) {
/* Show hunk marks, except for the first file. */
if (opt->last_shown)
opt->show_hunk_mark = 1;