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>
This commit is contained in:
Glen Choo 2023-06-28 19:26:20 +00:00 committed by Junio C Hamano
parent 6ff334181c
commit 97eeeea2dc
8 changed files with 26 additions and 20 deletions

View File

@ -365,7 +365,10 @@ static int add_config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
return git_color_default_config(var, value, cb); if (git_color_config(var, value, cb) < 0)
return -1;
return git_default_config(var, value, cb);
} }
static const char embedded_advice[] = N_( static const char embedded_advice[] = N_(

View File

@ -117,7 +117,10 @@ static int git_branch_config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
return git_color_default_config(var, value, cb); if (git_color_config(var, value, cb) < 0)
return -1;
return git_default_config(var, value, cb);
} }
static const char *branch_get_color(enum color_branch ix) static const char *branch_get_color(enum color_branch ix)

View File

@ -130,8 +130,10 @@ static int git_clean_config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
/* inspect the color.ui config variable and others */ if (git_color_config(var, value, cb) < 0)
return git_color_default_config(var, value, cb); return -1;
return git_default_config(var, value, cb);
} }
static const char *clean_get_color(enum color_clean ix) static const char *clean_get_color(enum color_clean ix)

View File

@ -293,7 +293,10 @@ static int wait_all(void)
static int grep_cmd_config(const char *var, const char *value, void *cb) static int grep_cmd_config(const char *var, const char *value, void *cb)
{ {
int st = grep_config(var, value, cb); int st = grep_config(var, value, cb);
if (git_color_default_config(var, value, NULL) < 0)
if (git_color_config(var, value, cb) < 0)
st = -1;
else if (git_default_config(var, value, cb) < 0)
st = -1; st = -1;
if (!strcmp(var, "grep.threads")) { if (!strcmp(var, "grep.threads")) {

View File

@ -579,7 +579,10 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
return git_color_default_config(var, value, cb); if (git_color_config(var, value, cb) < 0)
return -1;
return git_default_config(var, value, cb);
} }
static int omit_in_dense(struct commit *commit, struct commit **rev, int n) static int omit_in_dense(struct commit *commit, struct commit **rev, int n)

View File

@ -209,7 +209,11 @@ static int git_tag_config(const char *var, const char *value, void *cb)
if (starts_with(var, "column.")) if (starts_with(var, "column."))
return git_column_config(var, value, "tag", &colopts); return git_column_config(var, value, "tag", &colopts);
return git_color_default_config(var, value, cb);
if (git_color_config(var, value, cb) < 0)
return -1;
return git_default_config(var, value, cb);
} }
static void write_tag_body(int fd, const struct object_id *oid) static void write_tag_body(int fd, const struct object_id *oid)

View File

@ -430,14 +430,6 @@ int git_color_config(const char *var, const char *value, void *cb UNUSED)
return 0; return 0;
} }
int git_color_default_config(const char *var, const char *value, void *cb)
{
if (git_color_config(var, value, cb) < 0)
return -1;
return git_default_config(var, value, cb);
}
void color_print_strbuf(FILE *fp, const char *color, const struct strbuf *sb) void color_print_strbuf(FILE *fp, const char *color, const struct strbuf *sb)
{ {
if (*color) if (*color)

View File

@ -88,12 +88,8 @@ extern const int column_colors_ansi_max;
*/ */
extern int color_stdout_is_tty; extern int color_stdout_is_tty;
/* /* Parse color config. */
* Use the first one if you need only color config; the second is a convenience
* if you are just going to change to git_default_config, too.
*/
int git_color_config(const char *var, const char *value, void *cb); int git_color_config(const char *var, const char *value, void *cb);
int git_color_default_config(const char *var, const char *value, void *cb);
/* /*
* Parse a config option, which can be a boolean or one of * Parse a config option, which can be a boolean or one of