From: Stefan Beller Date: Fri, 23 Jun 2017 01:28:59 GMT Subject: [PATCHv2 05/25] diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_MARKER Message-ID: <20170623012919.28693-6-sbeller@google.com> In-Reply-To: <20170623012919.28693-1-sbeller@google.com> Signed-off-by: Stefan Beller --- diff.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/diff.c b/diff.c index 2257d44e2c..c550f75195 100644 --- a/diff.c +++ b/diff.c @@ -560,13 +560,20 @@ static void emit_line(struct diff_options *o, const char *set, const char *reset } enum diff_symbol { + DIFF_SYMBOL_CONTEXT_MARKER, DIFF_SYMBOL_SEPARATOR }; static void emit_diff_symbol(struct diff_options *o, enum diff_symbol s, const char *line, int len) { + const char *context, *reset; switch (s) { + case DIFF_SYMBOL_CONTEXT_MARKER: + context = diff_get_color_opt(o, DIFF_CONTEXT); + reset = diff_get_color_opt(o, DIFF_RESET); + emit_line(o, context, reset, line, len); + break; case DIFF_SYMBOL_SEPARATOR: fprintf(o->file, "%s%c", diff_line_prefix(o), @@ -661,7 +668,8 @@ static void emit_hunk_header(struct emit_callback *ecbdata, if (len < 10 || memcmp(line, atat, 2) || !(ep = memmem(line + 2, len - 2, atat, 2))) { - emit_line(ecbdata->opt, context, reset, line, len); + emit_diff_symbol(ecbdata->opt, + DIFF_SYMBOL_CONTEXT_MARKER, line, len); return; } ep += 2; /* skip over @@ */ -- 2.12.2.575.gb14f27f917