]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: inline git_color_default_config
authorGlen Choo <chooglen@google.com>
Wed, 28 Jun 2023 19:26:20 +0000 (19:26 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Jun 2023 21:06:38 +0000 (14:06 -0700)
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>
builtin/add.c
builtin/branch.c
builtin/clean.c
builtin/grep.c
builtin/show-branch.c
builtin/tag.c
color.c
color.h

index 6137e7b4ad7b01b9b37681b7332242e99ab5fe19..e01efdfc50d5708d6e53a82b55e06acf23ec6f8b 100644 (file)
@@ -365,7 +365,10 @@ static int add_config(const char *var, const char *value, void *cb)
                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_(
index 075e580d224108febf7a59b767d0ab099b8234c3..8337b9e71bb3a814d5d0dda7e5739c6afa1d0afa 100644 (file)
@@ -117,7 +117,10 @@ static int git_branch_config(const char *var, const char *value, void *cb)
                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)
index 78852d28cecb579e824cec08aa56633f411bdcac..57e7f7cac64353fc545604733638402d26ad8b9d 100644 (file)
@@ -130,8 +130,10 @@ static int git_clean_config(const char *var, const char *value, void *cb)
                return 0;
        }
 
-       /* inspect the color.ui config variable and others */
-       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 *clean_get_color(enum color_clean ix)
index b86c754defbc59654a6e455b2115487ba01f084f..76cf999d3105ffde5ee738bfd0a9594d14990dcf 100644 (file)
@@ -293,7 +293,10 @@ static int wait_all(void)
 static int grep_cmd_config(const char *var, const char *value, void *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;
 
        if (!strcmp(var, "grep.threads")) {
index 7ef4a642c17a63ba2060a1f5731c05a8d8d88a25..a2461270d4b494a2757cd1942c462c0a5155c4d4 100644 (file)
@@ -579,7 +579,10 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
                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)
index 49b64c7a2883b586015931869acf3878f33de299..1acf5f7a59fd49ab09cc0987a6f62fe97b78a98e 100644 (file)
@@ -209,7 +209,11 @@ static int git_tag_config(const char *var, const char *value, void *cb)
 
        if (starts_with(var, "column."))
                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)
diff --git a/color.c b/color.c
index 83abb11eda095e15e2b33a4588cecaa6eb1c3a28..b24b19566b99eb498859ed315b74cabcf6df37c1 100644 (file)
--- a/color.c
+++ b/color.c
@@ -430,14 +430,6 @@ int git_color_config(const char *var, const char *value, void *cb UNUSED)
        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)
 {
        if (*color)
diff --git a/color.h b/color.h
index cfc8f841b237c72a0a2ea8b7e42d58dc1cab5f9f..bb28343be210643b57201c6a68ac4f718fa8ebc8 100644 (file)
--- a/color.h
+++ b/color.h
@@ -88,12 +88,8 @@ extern const int column_colors_ansi_max;
  */
 extern int color_stdout_is_tty;
 
-/*
- * 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.
- */
+/* Parse color config. */
 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