Skip to content

Commit 9e1a5eb

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cb682f8 commit 9e1a5eb

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

diff.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@ static char diff_colors[][COLOR_MAXLEN] = {
5252
GIT_COLOR_NORMAL, /* FUNCINFO */
5353
};
5454

55-
static int parse_diff_color_slot(const char *var, int ofs)
55+
static int parse_diff_color_slot(const char *var)
5656
{
57-
if (!strcasecmp(var+ofs, "plain"))
57+
if (!strcasecmp(var, "plain"))
5858
return DIFF_PLAIN;
59-
if (!strcasecmp(var+ofs, "meta"))
59+
if (!strcasecmp(var, "meta"))
6060
return DIFF_METAINFO;
61-
if (!strcasecmp(var+ofs, "frag"))
61+
if (!strcasecmp(var, "frag"))
6262
return DIFF_FRAGINFO;
63-
if (!strcasecmp(var+ofs, "old"))
63+
if (!strcasecmp(var, "old"))
6464
return DIFF_FILE_OLD;
65-
if (!strcasecmp(var+ofs, "new"))
65+
if (!strcasecmp(var, "new"))
6666
return DIFF_FILE_NEW;
67-
if (!strcasecmp(var+ofs, "commit"))
67+
if (!strcasecmp(var, "commit"))
6868
return DIFF_COMMIT;
69-
if (!strcasecmp(var+ofs, "whitespace"))
69+
if (!strcasecmp(var, "whitespace"))
7070
return DIFF_WHITESPACE;
71-
if (!strcasecmp(var+ofs, "func"))
71+
if (!strcasecmp(var, "func"))
7272
return DIFF_FUNCINFO;
7373
return -1;
7474
}
@@ -240,7 +240,7 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
240240
return -1;
241241

242242
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);
244244
if (slot < 0)
245245
return 0;
246246
if (!value)

0 commit comments

Comments
 (0)