summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2017-06-29 17:06:50 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-30 13:13:01 -0700
commitc64b420b4c393c369d738cea00fb4ddac062c963 (patch)
tree6b7b4b121756395395ae1095e11cf0d2728d7d70 /diff.c
parent36a4cefdf4679c0988eab6d86c5cf3189785f29b (diff)
downloadgit-c64b420b4c393c369d738cea00fb4ddac062c963.tar.gz
diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_MARKER
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 4637368d59..75b996c4cf 100644
--- a/diff.c
+++ b/diff.c
@@ -561,13 +561,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),
@@ -662,7 +669,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 @@ */