summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-04-03 12:28:39 -0700
committerJunio C Hamano <gitster@pobox.com>2010-04-03 12:28:39 -0700
commit07b838f087a1535e387d5d4a1414b2b545b73265 (patch)
tree8779dd5e4854e5dd9c3dbe09daa80eea0ed0c7da /grep.c
parentd718dd0732c125306670d61880652f1b596a0c3e (diff)
parent431d6e7bc85f693fe49a04142a8ab4d2d72b0257 (diff)
downloadgit-07b838f087a1535e387d5d4a1414b2b545b73265.tar.gz
Merge branch 'rs/threaded-grep-context'
* rs/threaded-grep-context: grep: enable threading for context line printing Conflicts: grep.c
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/grep.c b/grep.c
index fdc4206268..543b1d5378 100644
--- a/grep.c
+++ b/grep.c
@@ -570,8 +570,7 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
if (opt->show_hunk_mark) {
output_color(opt, "--", 2, opt->color_sep);
opt->output(opt, "\n", 1);
- } else
- opt->show_hunk_mark = 1;
+ }
} else if (lno > opt->last_shown + 1) {
output_color(opt, "--", 2, opt->color_sep);
opt->output(opt, "\n", 1);
@@ -772,14 +771,6 @@ int grep_threads_ok(const struct grep_opt *opt)
!opt->name_only)
return 0;
- /* If we are showing hunk marks, we should not do it for the
- * first match. The synchronization problem we get for this
- * constraint is not yet solved, so we disable threading in
- * this case.
- */
- if (opt->pre_context || opt->post_context)
- return 0;
-
return 1;
}
@@ -801,11 +792,14 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
enum grep_context ctx = GREP_CONTEXT_HEAD;
xdemitconf_t xecfg;
- opt->last_shown = 0;
-
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;
+ opt->last_shown = 0;
+
if (buffer_is_binary(buf, size)) {
switch (opt->binary) {
case GREP_BINARY_DEFAULT: