diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-06-29 17:03:13 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-06-29 17:03:13 -0700 |
commit | 1692d0c64a6386ae08d12ed90c9d975911451cbe (patch) | |
tree | 94398b8e23fa0f5f15fce10a128aa0757e3ad3e6 /grep.c | |
parent | b985f2aecaa6358b55d545385d0624d76ff83fb8 (diff) | |
parent | 1d84f72ef1dee1f851e11a6d92e8ab3f1979b2a2 (diff) | |
download | git-1692d0c64a6386ae08d12ed90c9d975911451cbe.tar.gz |
Merge branch 'rs/grep-color'
* rs/grep-color:
grep: add --heading
grep: add --break
grep: fix coloring of hunk marks between files
Diffstat (limited to 'grep.c')
-rw-r--r-- | grep.c | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -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); @@ -732,9 +735,13 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol, opt->output(opt, "\n", 1); } } + if (opt->heading && opt->last_shown == 0) { + output_color(opt, name, strlen(name), opt->color_filename); + opt->output(opt, "\n", 1); + } opt->last_shown = lno; - if (opt->pathname) { + if (!opt->heading && opt->pathname) { output_color(opt, name, strlen(name), opt->color_filename); output_sep(opt, sign); } @@ -941,9 +948,18 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name, if (!opt->output) opt->output = std_output; - if (opt->last_shown && (opt->pre_context || opt->post_context) && - opt->output == std_output) - opt->show_hunk_mark = 1; + 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; + /* + * If we're using threads then we can't easily identify + * the first file. Always put hunk marks in that case + * and skip the very first one later in work_done(). + */ + if (opt->output != std_output) + opt->show_hunk_mark = 1; + } opt->last_shown = 0; switch (opt->binary) { |