mirror of
https://github.com/git/git.git
synced 2024-11-28 04:23:30 +08:00
diff.c: emit_diff_symbol learns DIFF_SYMBOL_WORDS[_PORCELAIN]
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
091f8e28b4
commit
ff958679cd
42
diff.c
42
diff.c
@ -561,6 +561,8 @@ static void emit_line(struct diff_options *o, const char *set, const char *reset
|
||||
}
|
||||
|
||||
enum diff_symbol {
|
||||
DIFF_SYMBOL_WORDS_PORCELAIN,
|
||||
DIFF_SYMBOL_WORDS,
|
||||
DIFF_SYMBOL_CONTEXT,
|
||||
DIFF_SYMBOL_PLUS,
|
||||
DIFF_SYMBOL_MINUS,
|
||||
@ -649,6 +651,26 @@ static void emit_diff_symbol(struct diff_options *o, enum diff_symbol s,
|
||||
emit_line_ws_markup(o, set, reset, line, len, '-',
|
||||
flags & DIFF_SYMBOL_CONTENT_WS_MASK, 0);
|
||||
break;
|
||||
case DIFF_SYMBOL_WORDS_PORCELAIN:
|
||||
context = diff_get_color_opt(o, DIFF_CONTEXT);
|
||||
reset = diff_get_color_opt(o, DIFF_RESET);
|
||||
emit_line(o, context, reset, line, len);
|
||||
fputs("~\n", o->file);
|
||||
break;
|
||||
case DIFF_SYMBOL_WORDS:
|
||||
context = diff_get_color_opt(o, DIFF_CONTEXT);
|
||||
reset = diff_get_color_opt(o, DIFF_RESET);
|
||||
/*
|
||||
* Skip the prefix character, if any. With
|
||||
* diff_suppress_blank_empty, there may be
|
||||
* none.
|
||||
*/
|
||||
if (line[0] != '\n') {
|
||||
line++;
|
||||
len--;
|
||||
}
|
||||
emit_line(o, context, reset, line, len);
|
||||
break;
|
||||
default:
|
||||
die("BUG: unknown diff symbol");
|
||||
}
|
||||
@ -1342,7 +1364,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
||||
{
|
||||
struct emit_callback *ecbdata = priv;
|
||||
const char *meta = diff_get_color(ecbdata->color_diff, DIFF_METAINFO);
|
||||
const char *context = diff_get_color(ecbdata->color_diff, DIFF_CONTEXT);
|
||||
const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
|
||||
struct diff_options *o = ecbdata->opt;
|
||||
const char *line_prefix = diff_line_prefix(o);
|
||||
@ -1384,6 +1405,9 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
||||
}
|
||||
|
||||
if (ecbdata->diff_words) {
|
||||
enum diff_symbol s =
|
||||
ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN ?
|
||||
DIFF_SYMBOL_WORDS_PORCELAIN : DIFF_SYMBOL_WORDS;
|
||||
if (line[0] == '-') {
|
||||
diff_words_append(line, len,
|
||||
&ecbdata->diff_words->minus);
|
||||
@ -1403,21 +1427,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
||||
return;
|
||||
}
|
||||
diff_words_flush(ecbdata);
|
||||
if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
|
||||
emit_line(o, context, reset, line, len);
|
||||
fputs("~\n", o->file);
|
||||
} else {
|
||||
/*
|
||||
* Skip the prefix character, if any. With
|
||||
* diff_suppress_blank_empty, there may be
|
||||
* none.
|
||||
*/
|
||||
if (line[0] != '\n') {
|
||||
line++;
|
||||
len--;
|
||||
}
|
||||
emit_line(o, context, reset, line, len);
|
||||
}
|
||||
emit_diff_symbol(o, s, line, len, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user