checkdiff: pass diff_options to the callback
This way, we could later use more information from the diff_options. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jun 26, 2008 at 15:36 UTC
1ba111d1d6bd90b2c120ceb05418e01ee304cc46
1 file changed
+11
-10
diff.c
+11
-10
@@ -1136,18 +1136,19 @@ static void free_diffstat_info(struct diffstat_t *diffstat)
1136
struct checkdiff_t {
1137
struct xdiff_emit_state xm;
1138
const char *filename;
1139
- int lineno, color_diff;
1139
+ int lineno;
1140
+ struct diff_options *o;
1141
unsigned ws_rule;
1142
unsigned status;
1142
- FILE *file;
1143
};
1144
1145
static void checkdiff_consume(void *priv, char *line, unsigned long len)
1146
{
1147
struct checkdiff_t *data = priv;
1148
- const char *ws = diff_get_color(data->color_diff, DIFF_WHITESPACE);
1149
- const char *reset = diff_get_color(data->color_diff, DIFF_RESET);
1150
- const char *set = diff_get_color(data->color_diff, DIFF_FILE_NEW);
1148
+ int color_diff = DIFF_OPT_TST(data->o, COLOR_DIFF);
1149
+ const char *ws = diff_get_color(color_diff, DIFF_WHITESPACE);
1150
+ const char *reset = diff_get_color(color_diff, DIFF_RESET);
1151
+ const char *set = diff_get_color(color_diff, DIFF_FILE_NEW);
1152
char *err;
1153
1154
if (line[0] == '+') {
@@ -1158,11 +1159,12 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
1159
return;
1160
data->status |= bad;
1161
err = whitespace_error_string(bad);
1161
- fprintf(data->file, "%s:%d: %s.\n", data->filename, data->lineno, err);
1162
+ fprintf(data->o->file, "%s:%d: %s.\n",
1163
+ data->filename, data->lineno, err);
1164
free(err);
1163
- emit_line(data->file, set, reset, line, 1);
1165
+ emit_line(data->o->file, set, reset, line, 1);
1166
ws_check_emit(line + 1, len - 1, data->ws_rule,
1165
- data->file, set, reset, ws);
1167
+ data->o->file, set, reset, ws);
1168
} else if (line[0] == ' ')
1169
data->lineno++;
1170
else if (line[0] == '@') {
@@ -1557,9 +1559,8 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
1559
data.xm.consume = checkdiff_consume;
1560
data.filename = name_b ? name_b : name_a;
1561
data.lineno = 0;
1560
- data.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);
1562
+ data.o = o;
1563
data.ws_rule = whitespace_rule(attr_path);
1562
- data.file = o->file;
1564
1565
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
1566
die("unable to read files to diff");