From e9330ae4b820147c98e723399e9438c8bee60a80 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 16 Sep 2025 19:13:59 -0400 Subject: color: use git_colorbool enum type to store colorbools We traditionally used "int" to store and pass around the values defined by "enum git_colorbool" (which were originally just #define macros). Using an int doesn't produce incorrect results, but using the actual enum makes the intent of the code more clear. It would be nice if the compiler could catch cases where we used the enum and an int interchangeably, since it's very easy to accidentally check the boolean true/false of a colorbool like: if (branch_use_color) This is wrong because GIT_COLOR_UNKNOWN and GIT_COLOR_AUTO evaluate to true in C, even though we may ultimately decide not to use color. But C is pretty happy to convert between ints and enums (even with various -Wenum-* warnings). So this sadly doesn't protect us from such mistakes, but it hopefully does make the code easier to read. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- combine-diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'combine-diff.c') diff --git a/combine-diff.c b/combine-diff.c index 4ea2dc93c4..9b4deeebeb 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -749,7 +749,7 @@ static void show_line_to_eol(const char *line, int len, const char *reset) static void dump_sline(struct sline *sline, const char *line_prefix, unsigned long cnt, int num_parent, - int use_color, int result_deleted) + enum git_colorbool use_color, int result_deleted) { unsigned long mark = (1UL<