parse_diff_color_slot: drop ofs parameter
This function originally took a whole config variable name ("var") and an offset ("ofs"). It checked "var+ofs" against each color slot, but reported errors using the whole "var". However, since 8b8e862 (ignore unknown color configuration, 2009-12-12), it returns -1 rather than printing its own error, and therefore only cares about var+ofs. We can drop the ofs parameter and teach its sole caller to derive the pointer itself. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 18, 2014 at 15:41 UTC
9e1a5ebe52d84c35eee18a896ad1b8bab53cadbf
1 file changed
+10
-10
diff.c
+10
-10
@@ -52,23 +52,23 @@ static char diff_colors[][COLOR_MAXLEN] = {
52
GIT_COLOR_NORMAL, /* FUNCINFO */
53
};
54
55
-static int parse_diff_color_slot(const char *var, int ofs)
55
+static int parse_diff_color_slot(const char *var)
56
{
57
- if (!strcasecmp(var+ofs, "plain"))
57
+ if (!strcasecmp(var, "plain"))
58
return DIFF_PLAIN;
59
- if (!strcasecmp(var+ofs, "meta"))
59
+ if (!strcasecmp(var, "meta"))
60
return DIFF_METAINFO;
61
- if (!strcasecmp(var+ofs, "frag"))
61
+ if (!strcasecmp(var, "frag"))
62
return DIFF_FRAGINFO;
63
- if (!strcasecmp(var+ofs, "old"))
63
+ if (!strcasecmp(var, "old"))
64
return DIFF_FILE_OLD;
65
- if (!strcasecmp(var+ofs, "new"))
65
+ if (!strcasecmp(var, "new"))
66
return DIFF_FILE_NEW;
67
- if (!strcasecmp(var+ofs, "commit"))
67
+ if (!strcasecmp(var, "commit"))
68
return DIFF_COMMIT;
69
- if (!strcasecmp(var+ofs, "whitespace"))
69
+ if (!strcasecmp(var, "whitespace"))
70
return DIFF_WHITESPACE;
71
- if (!strcasecmp(var+ofs, "func"))
71
+ if (!strcasecmp(var, "func"))
72
return DIFF_FUNCINFO;
73
return -1;
74
}
@@ -240,7 +240,7 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
240
return -1;
241
242
if (starts_with(var, "diff.color.") || starts_with(var, "color.diff.")) {
243
- int slot = parse_diff_color_slot(var, 11);
243
+ int slot = parse_diff_color_slot(var + 11);
244
if (slot < 0)
245
return 0;
246
if (!value)