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 <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Glen Choo committed Jun 28, 2023 at 19:26 UTC 97eeeea2dc069a1fcb03db99ef3810ebe3056188
8 files changed +26 -20
builtin/add.c
+4 -1
@@ -365,7 +365,10 @@ static int add_config(const char *var, const char *value, void *cb)
365 return 0;
366 }
367
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);
372 }
373
374 static const char embedded_advice[] = N_(
builtin/branch.c
+4 -1
@@ -117,7 +117,10 @@ static int git_branch_config(const char *var, const char *value, void *cb)
117 return 0;
118 }
119
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);
124 }
125
126 static const char *branch_get_color(enum color_branch ix)
builtin/clean.c
+4 -2
@@ -130,8 +130,10 @@ static int git_clean_config(const char *var, const char *value, void *cb)
130 return 0;
131 }
132
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);
137 }
138
139 static const char *clean_get_color(enum color_clean ix)
builtin/grep.c
+4 -1
@@ -293,7 +293,10 @@ static int wait_all(void)
293 static int grep_cmd_config(const char *var, const char *value, void *cb)
294 {
295 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)
300 st = -1;
301
302 if (!strcmp(var, "grep.threads")) {
builtin/show-branch.c
+4 -1
@@ -579,7 +579,10 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
579 return 0;
580 }
581
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);
586 }
587
588 static int omit_in_dense(struct commit *commit, struct commit **rev, int n)
builtin/tag.c
+5 -1
@@ -209,7 +209,11 @@ static int git_tag_config(const char *var, const char *value, void *cb)
209
210 if (starts_with(var, "column."))
211 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);
217 }
218
219 static void write_tag_body(int fd, const struct object_id *oid)
color.c
-8
@@ -430,14 +430,6 @@ int git_color_config(const char *var, const char *value, void *cb UNUSED)
430 return 0;
431 }
432
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 -
433 void color_print_strbuf(FILE *fp, const char *color, const struct strbuf *sb)
434 {
435 if (*color)
color.h
+1 -5
@@ -88,12 +88,8 @@ extern const int column_colors_ansi_max;
88 */
89 extern int color_stdout_is_tty;
90
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. */
92 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);
93
94 /*
95 * Parse a config option, which can be a boolean or one of