Skip to content

Commit 97eeeea

Browse files
chooglengitster
authored andcommitted
config: inline git_color_default_config
git_color_default_config() is a shorthand for calling two other config callbacks. There are no other non-static functions that do this and it will complicate our refactoring of config_fn_t so inline it instead. Signed-off-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6ff3341 commit 97eeeea

File tree

8 files changed

+26
-20
lines changed

8 files changed

+26
-20
lines changed

builtin/add.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ static int add_config(const char *var, const char *value, void *cb)
365365
return 0;
366366
}
367367

368-
return git_color_default_config(var, value, cb);
368+
if (git_color_config(var, value, cb) < 0)
369+
return -1;
370+
371+
return git_default_config(var, value, cb);
369372
}
370373

371374
static const char embedded_advice[] = N_(

builtin/branch.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ static int git_branch_config(const char *var, const char *value, void *cb)
117117
return 0;
118118
}
119119

120-
return git_color_default_config(var, value, cb);
120+
if (git_color_config(var, value, cb) < 0)
121+
return -1;
122+
123+
return git_default_config(var, value, cb);
121124
}
122125

123126
static const char *branch_get_color(enum color_branch ix)

builtin/clean.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ static int git_clean_config(const char *var, const char *value, void *cb)
130130
return 0;
131131
}
132132

133-
/* inspect the color.ui config variable and others */
134-
return git_color_default_config(var, value, cb);
133+
if (git_color_config(var, value, cb) < 0)
134+
return -1;
135+
136+
return git_default_config(var, value, cb);
135137
}
136138

137139
static const char *clean_get_color(enum color_clean ix)

builtin/grep.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ static int wait_all(void)
293293
static int grep_cmd_config(const char *var, const char *value, void *cb)
294294
{
295295
int st = grep_config(var, value, cb);
296-
if (git_color_default_config(var, value, NULL) < 0)
296+
297+
if (git_color_config(var, value, cb) < 0)
298+
st = -1;
299+
else if (git_default_config(var, value, cb) < 0)
297300
st = -1;
298301

299302
if (!strcmp(var, "grep.threads")) {

builtin/show-branch.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,10 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
579579
return 0;
580580
}
581581

582-
return git_color_default_config(var, value, cb);
582+
if (git_color_config(var, value, cb) < 0)
583+
return -1;
584+
585+
return git_default_config(var, value, cb);
583586
}
584587

585588
static int omit_in_dense(struct commit *commit, struct commit **rev, int n)

builtin/tag.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ static int git_tag_config(const char *var, const char *value, void *cb)
209209

210210
if (starts_with(var, "column."))
211211
return git_column_config(var, value, "tag", &colopts);
212-
return git_color_default_config(var, value, cb);
212+
213+
if (git_color_config(var, value, cb) < 0)
214+
return -1;
215+
216+
return git_default_config(var, value, cb);
213217
}
214218

215219
static void write_tag_body(int fd, const struct object_id *oid)

color.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,6 @@ int git_color_config(const char *var, const char *value, void *cb UNUSED)
430430
return 0;
431431
}
432432

433-
int git_color_default_config(const char *var, const char *value, void *cb)
434-
{
435-
if (git_color_config(var, value, cb) < 0)
436-
return -1;
437-
438-
return git_default_config(var, value, cb);
439-
}
440-
441433
void color_print_strbuf(FILE *fp, const char *color, const struct strbuf *sb)
442434
{
443435
if (*color)

color.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,8 @@ extern const int column_colors_ansi_max;
8888
*/
8989
extern int color_stdout_is_tty;
9090

91-
/*
92-
* Use the first one if you need only color config; the second is a convenience
93-
* if you are just going to change to git_default_config, too.
94-
*/
91+
/* Parse color config. */
9592
int git_color_config(const char *var, const char *value, void *cb);
96-
int git_color_default_config(const char *var, const char *value, void *cb);
9793

9894
/*
9995
* Parse a config option, which can be a boolean or one of

0 commit comments

Comments
 (0)