diff: drop unused color reset parameters
Several of the emit_* functions take a "reset" color parameter, but never actually look at it (instead, they call into emit_diff_symbol, which handles the colors itself). Let's drop these unused parameters. Note that emit_line() does still take a color/reset pair, and actually uses it. It cannot be refactored to match these other functions because it's the thing that emit_diff_symbol eventually calls into (i.e., it does not by itself know which colors to use, and must be told by the caller). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Feb 14, 2019 at 00:48 UTC
e04df61256a40e860dfcc5518fd4f0558c8c2f03
1 file changed
+8
-13
diff.c
+8
-13
@@ -1613,8 +1613,7 @@ static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line
1613
return ws_blank_line(line, len, ecbdata->ws_rule);
1614
}
1615
1616
-static void emit_add_line(const char *reset,
1617
- struct emit_callback *ecbdata,
1616
+static void emit_add_line(struct emit_callback *ecbdata,
1617
const char *line, int len)
1618
{
1619
unsigned flags = WSEH_NEW | ecbdata->ws_rule;
@@ -1624,16 +1623,14 @@ static void emit_add_line(const char *reset,
1623
emit_diff_symbol(ecbdata->opt, DIFF_SYMBOL_PLUS, line, len, flags);
1624
}
1625
1627
-static void emit_del_line(const char *reset,
1628
- struct emit_callback *ecbdata,
1626
+static void emit_del_line(struct emit_callback *ecbdata,
1627
const char *line, int len)
1628
{
1629
unsigned flags = WSEH_OLD | ecbdata->ws_rule;
1630
emit_diff_symbol(ecbdata->opt, DIFF_SYMBOL_MINUS, line, len, flags);
1631
}
1632
1635
-static void emit_context_line(const char *reset,
1636
- struct emit_callback *ecbdata,
1633
+static void emit_context_line(struct emit_callback *ecbdata,
1634
const char *line, int len)
1635
{
1636
unsigned flags = WSEH_CONTEXT | ecbdata->ws_rule;
@@ -1742,7 +1739,6 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
1739
int prefix, const char *data, int size)
1740
{
1741
const char *endp = NULL;
1745
- const char *reset = diff_get_color(ecb->color_diff, DIFF_RESET);
1742
1743
while (0 < size) {
1744
int len;
@@ -1751,10 +1747,10 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
1747
len = endp ? (endp - data + 1) : size;
1748
if (prefix != '+') {
1749
ecb->lno_in_preimage++;
1754
- emit_del_line(reset, ecb, data, len);
1750
+ emit_del_line(ecb, data, len);
1751
} else {
1752
ecb->lno_in_postimage++;
1757
- emit_add_line(reset, ecb, data, len);
1753
+ emit_add_line(ecb, data, len);
1754
}
1755
size -= len;
1756
data += len;
@@ -2325,7 +2321,6 @@ static void find_lno(const char *line, struct emit_callback *ecbdata)
2321
static void fn_out_consume(void *priv, char *line, unsigned long len)
2322
{
2323
struct emit_callback *ecbdata = priv;
2328
- const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
2324
struct diff_options *o = ecbdata->opt;
2325
2326
o->found_changes = 1;
@@ -2392,16 +2387,16 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
2387
switch (line[0]) {
2388
case '+':
2389
ecbdata->lno_in_postimage++;
2395
- emit_add_line(reset, ecbdata, line + 1, len - 1);
2390
+ emit_add_line(ecbdata, line + 1, len - 1);
2391
break;
2392
case '-':
2393
ecbdata->lno_in_preimage++;
2399
- emit_del_line(reset, ecbdata, line + 1, len - 1);
2394
+ emit_del_line(ecbdata, line + 1, len - 1);
2395
break;
2396
case ' ':
2397
ecbdata->lno_in_postimage++;
2398
ecbdata->lno_in_preimage++;
2404
- emit_context_line(reset, ecbdata, line + 1, len - 1);
2399
+ emit_context_line(ecbdata, line + 1, len - 1);
2400
break;
2401
default:
2402
/* incomplete line at the end */