From f1c9626105d5e4962a5ccaa4620114d03f32ad02 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 17 Aug 2011 22:03:12 -0700 Subject: diff: refactor COLOR_DIFF from a flag into an int This lets us store more than just a bit flag for whether we want color; we can also store whether we want automatic colors. This can be useful for making the automatic-color decision closer to the point of use. This mostly just involves replacing DIFF_OPT_* calls with manipulations of the flag. The biggest exception is that calls to DIFF_OPT_TST must check for "o->use_color > 0", which lets an "unknown" value (i.e., the default) stay at "no color". In the previous code, a value of "-1" was not propagated at all. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'diff.h') diff --git a/diff.h b/diff.h index 6d303c1d50..04a9ad781b 100644 --- a/diff.h +++ b/diff.h @@ -58,7 +58,7 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data) #define DIFF_OPT_SILENT_ON_REMOVE (1 << 5) #define DIFF_OPT_FIND_COPIES_HARDER (1 << 6) #define DIFF_OPT_FOLLOW_RENAMES (1 << 7) -#define DIFF_OPT_COLOR_DIFF (1 << 8) +/* (1 << 8) unused */ /* (1 << 9) unused */ #define DIFF_OPT_HAS_CHANGES (1 << 10) #define DIFF_OPT_QUICK (1 << 11) @@ -101,6 +101,7 @@ struct diff_options { const char *single_follow; const char *a_prefix, *b_prefix; unsigned flags; + int use_color; int context; int interhunkcontext; int break_opt; @@ -159,7 +160,7 @@ enum color_diff { }; const char *diff_get_color(int diff_use_color, enum color_diff ix); #define diff_get_color_opt(o, ix) \ - diff_get_color(DIFF_OPT_TST((o), COLOR_DIFF), ix) + diff_get_color((o)->use_color, ix) extern const char mime_boundary_leader[]; -- cgit v1.2.3