summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8f8841e)
raw | patch | inline | side by side (parent: 8f8841e)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 26 Jun 2008 22:36:34 +0000 (15:36 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 27 Jun 2008 05:06:09 +0000 (22:06 -0700) |
This way, we could later use more information from the diff_options.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history |
index 52a34eec913432a8928823e195c10875afd86d21..6bcbe2082873c7f311931890d39afdbd5345838d 100644 (file)
--- a/diff.c
+++ b/diff.c
struct checkdiff_t {
struct xdiff_emit_state xm;
const char *filename;
- int lineno, color_diff;
+ int lineno;
+ struct diff_options *o;
unsigned ws_rule;
unsigned status;
- FILE *file;
};
static void checkdiff_consume(void *priv, char *line, unsigned long len)
{
struct checkdiff_t *data = priv;
- const char *ws = diff_get_color(data->color_diff, DIFF_WHITESPACE);
- const char *reset = diff_get_color(data->color_diff, DIFF_RESET);
- const char *set = diff_get_color(data->color_diff, DIFF_FILE_NEW);
+ int color_diff = DIFF_OPT_TST(data->o, COLOR_DIFF);
+ const char *ws = diff_get_color(color_diff, DIFF_WHITESPACE);
+ const char *reset = diff_get_color(color_diff, DIFF_RESET);
+ const char *set = diff_get_color(color_diff, DIFF_FILE_NEW);
char *err;
if (line[0] == '+') {
return;
data->status |= bad;
err = whitespace_error_string(bad);
- fprintf(data->file, "%s:%d: %s.\n", data->filename, data->lineno, err);
+ fprintf(data->o->file, "%s:%d: %s.\n",
+ data->filename, data->lineno, err);
free(err);
- emit_line(data->file, set, reset, line, 1);
+ emit_line(data->o->file, set, reset, line, 1);
ws_check_emit(line + 1, len - 1, data->ws_rule,
- data->file, set, reset, ws);
+ data->o->file, set, reset, ws);
} else if (line[0] == ' ')
data->lineno++;
else if (line[0] == '@') {
data.xm.consume = checkdiff_consume;
data.filename = name_b ? name_b : name_a;
data.lineno = 0;
- data.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);
+ data.o = o;
data.ws_rule = whitespace_rule(attr_path);
- data.file = o->file;
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
die("unable to read files to diff");