git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 01/12] config: inline git_color_default_config

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 20, 2023, 21:01 UTC
Message-ID
<xmqqjzvxlufa.fsf@gitster.g>
In-Reply-To
<26109b65142d2a325201940262a6c0bf183ec4bd.1687290232.git.gitgitgadget@gmail.com>
"Glen Choo via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 8 quoted lines
> From: Glen Choo <chooglen@google.com>
>
> 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>
> ---

We would need to deal with git_default_config() that is called from everywhere in exactly the same way, so I am not sure if the presence of git_color_default_config() will complicate so much to require this step while git_default_config() can be dealt with without inlining into its callers, but this change does not hurt anybody either.

OK.  
Show 128 quoted lines
>  builtin/branch.c      | 5 ++++-
>  builtin/clean.c       | 6 ++++--
>  builtin/grep.c        | 5 ++++-
>  builtin/show-branch.c | 5 ++++-
>  builtin/tag.c         | 6 +++++-
>  color.c               | 8 --------
>  color.h               | 6 +-----
>  7 files changed, 22 insertions(+), 19 deletions(-)
>
> diff --git a/builtin/branch.c b/builtin/branch.c
> index e6c2655af68..df99e38847b 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -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)
> diff --git a/builtin/clean.c b/builtin/clean.c
> index 78852d28cec..57e7f7cac64 100644
> --- a/builtin/clean.c
> +++ b/builtin/clean.c
> @@ -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)
> diff --git a/builtin/grep.c b/builtin/grep.c
> index b86c754defb..76cf999d310 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -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")) {
> diff --git a/builtin/show-branch.c b/builtin/show-branch.c
> index 7ef4a642c17..a2461270d4b 100644
> --- a/builtin/show-branch.c
> +++ b/builtin/show-branch.c
> @@ -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)
> diff --git a/builtin/tag.c b/builtin/tag.c
> index 49b64c7a288..1acf5f7a59f 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -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 83abb11eda0..b24b19566b9 100644
> --- 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 cfc8f841b23..bb28343be21 100644
> --- 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
Previous: Glen Choo via GitGitGadgetNext: Glen Choo via GitGitGadget
Message 59 of 115 in “[RFC] config: remove global state from config iteration”
  1. 00/14 [RFC] config: remove global state from config iterationGlen Choo via GitGitGadget, Apr 21, 2023
  2. 01/14 config.c: introduce kvi_fn(), use it for configsetsGlen Choo via GitGitGadget, Apr 21, 2023
  3. 02/14 config.c: use kvi for CLI configGlen Choo via GitGitGadget, Apr 21, 2023
  4. Ævar Arnfjörð BjarmasonMay 1, 2023
  5. 06/14 config: inline git_color_default_configGlen Choo via GitGitGadget, Apr 21, 2023
  6. 03/14 config: use kvi for config filesGlen Choo via GitGitGadget, Apr 21, 2023
  7. 04/14 config: add kvi.path, use it to evaluate includesGlen Choo via GitGitGadget, Apr 21, 2023
  8. 05/14 config: pass source to config_parser_event_fn_tGlen Choo via GitGitGadget, Apr 21, 2023
  9. 07/14 urlmatch.h: use config_fn_t typeGlen Choo via GitGitGadget, Apr 21, 2023
  10. 08/14 (RFC-only) config: add kvi arg to config_fn_tGlen Choo via GitGitGadget, Apr 21, 2023
  11. 10/14 (RFC-only) config: finish config_fn_t refactorGlen Choo via GitGitGadget, Apr 21, 2023
  12. Ævar Arnfjörð BjarmasonMay 1, 2023
  13. Jonathan TanMay 5, 2023
  14. Glen ChooMay 9, 2023
  15. Jonathan TanMay 11, 2023
  16. Glen ChooMay 8, 2023
  17. 11/14 config: remove current_config_(line|name|origin_type)Glen Choo via GitGitGadget, Apr 21, 2023
  18. 14/14 config: remove config_reader from configset_add_valueGlen Choo via GitGitGadget, Apr 21, 2023
  19. 12/14 config: remove current_config_scope()Glen Choo via GitGitGadget, Apr 21, 2023
  20. 09/14 (RFC-only) config: apply cocci to config_fn_t implementationsGlen Choo via GitGitGadget, Apr 21, 2023
  21. 13/14 config: pass kvi to die_bad_number()Glen Choo via GitGitGadget, Apr 21, 2023
  22. 00/14 [RFC] config: remove global state from config iterationGlen Choo via GitGitGadget, May 30, 2023
  23. 01/14 config: inline git_color_default_configGlen Choo via GitGitGadget, May 30, 2023
  24. 02/14 urlmatch.h: use config_fn_t typeGlen Choo via GitGitGadget, May 30, 2023
  25. 03/14 (RFC-only) config: add kvi arg to config_fn_tGlen Choo via GitGitGadget, May 30, 2023
  26. Phillip WoodJun 1, 2023
  27. Glen ChooJun 1, 2023
  28. Phillip WoodJun 2, 2023
  29. Glen ChooJun 2, 2023
  30. Phillip WoodJun 5, 2023
  31. Glen ChooJun 9, 2023
  32. 08/14 builtin/config.c: test misuse of format_config()Glen Choo via GitGitGadget, May 30, 2023
  33. 06/14 config.c: pass kvi in configsetsGlen Choo via GitGitGadget, May 30, 2023
  34. Jonathan TanJun 1, 2023
  35. 05/14 (RFC-only) config: finish config_fn_t refactorGlen Choo via GitGitGadget, May 30, 2023
  36. Jonathan TanJun 1, 2023
  37. 07/14 config: provide kvi with config filesGlen Choo via GitGitGadget, May 30, 2023
  38. Jonathan TanJun 1, 2023
  39. Jonathan TanJun 1, 2023
  40. 04/14 (RFC-only) config: apply cocci to config_fn_t implementationsGlen Choo via GitGitGadget, May 30, 2023
  41. 09/14 config.c: provide kvi with CLI configGlen Choo via GitGitGadget, May 30, 2023
  42. Jonathan TanJun 1, 2023
  43. Glen ChooJun 2, 2023
  44. 10/14 trace2: plumb config kviGlen Choo via GitGitGadget, May 30, 2023
  45. Jonathan TanJun 1, 2023
  46. 12/14 config.c: remove config_reader from configsetsGlen Choo via GitGitGadget, May 30, 2023
  47. 13/14 config: add kvi.path, use it to evaluate includesGlen Choo via GitGitGadget, May 30, 2023
  48. Jonathan TanJun 2, 2023
  49. 14/14 config: pass source to config_parser_event_fn_tGlen Choo via GitGitGadget, May 30, 2023
  50. Jonathan TanJun 2, 2023
  51. Glen ChooJun 2, 2023
  52. 11/14 config: pass kvi to die_bad_number()Glen Choo via GitGitGadget, May 30, 2023
  53. Jonathan TanJun 1, 2023
  54. Glen ChooJun 2, 2023
  55. 00/12 config: remove global state from config iterationGlen Choo via GitGitGadget, Jun 20, 2023
  56. 02/12 urlmatch.h: use config_fn_t typeGlen Choo via GitGitGadget, Jun 20, 2023
  57. Junio C HamanoJun 20, 2023
  58. 01/12 config: inline git_color_default_configGlen Choo via GitGitGadget, Jun 20, 2023
  59. Junio C HamanoJun 20, 2023
  60. 04/12 config.c: pass ctx in configsetsGlen Choo via GitGitGadget, Jun 20, 2023
  61. Junio C HamanoJun 20, 2023
  62. 05/12 config: pass ctx with config filesGlen Choo via GitGitGadget, Jun 20, 2023
  63. 06/12 builtin/config.c: test misuse of format_config()Glen Choo via GitGitGadget, Jun 20, 2023
  64. Junio C HamanoJun 20, 2023
  65. Glen ChooJun 20, 2023
  66. Jonathan TanJun 23, 2023
  67. Jeff KingJun 24, 2023
  68. Glen ChooJun 28, 2023
  69. 07/12 config.c: pass ctx with CLI configGlen Choo via GitGitGadget, Jun 20, 2023
  70. Jonathan TanJun 23, 2023
  71. Glen ChooJun 23, 2023
  72. 08/12 trace2: plumb config kviGlen Choo via GitGitGadget, Jun 20, 2023
  73. Jonathan TanJun 23, 2023
  74. 10/12 config.c: remove config_reader from configsetsGlen Choo via GitGitGadget, Jun 20, 2023
  75. Jonathan TanJun 23, 2023
  76. Junio C HamanoJun 23, 2023
  77. 03/12 config: add ctx arg to config_fn_tGlen Choo via GitGitGadget, Jun 20, 2023
  78. 11/12 config: add kvi.path, use it to evaluate includesGlen Choo via GitGitGadget, Jun 20, 2023
  79. 12/12 config: pass source to config_parser_event_fn_tGlen Choo via GitGitGadget, Jun 20, 2023
  80. Junio C HamanoJun 20, 2023
  81. 09/12 config: pass kvi to die_bad_number()Glen Choo via GitGitGadget, Jun 20, 2023
  82. Junio C HamanoJun 21, 2023
  83. Glen ChooJun 21, 2023
  84. Jonathan TanJun 23, 2023
  85. Junio C HamanoJun 23, 2023
  86. Glen ChooJun 23, 2023
  87. 00/12 config: remove global state from config iterationGlen Choo via GitGitGadget, Jun 26, 2023
  88. 01/12 config: inline git_color_default_configGlen Choo via GitGitGadget, Jun 26, 2023
  89. 02/12 urlmatch.h: use config_fn_t typeGlen Choo via GitGitGadget, Jun 26, 2023
  90. 04/12 config.c: pass ctx in configsetsGlen Choo via GitGitGadget, Jun 26, 2023
  91. 06/12 builtin/config.c: test misuse of format_config()Glen Choo via GitGitGadget, Jun 26, 2023
  92. 05/12 config: pass ctx with config filesGlen Choo via GitGitGadget, Jun 26, 2023
  93. 07/12 config.c: pass ctx with CLI configGlen Choo via GitGitGadget, Jun 26, 2023
  94. 08/12 trace2: plumb config kviGlen Choo via GitGitGadget, Jun 26, 2023
  95. 03/12 config: add ctx arg to config_fn_tGlen Choo via GitGitGadget, Jun 26, 2023
  96. 11/12 config: add kvi.path, use it to evaluate includesGlen Choo via GitGitGadget, Jun 26, 2023
  97. 12/12 config: pass source to config_parser_event_fn_tGlen Choo via GitGitGadget, Jun 26, 2023
  98. 10/12 config.c: remove config_reader from configsetsGlen Choo via GitGitGadget, Jun 26, 2023
  99. 09/12 config: pass kvi to die_bad_number()Glen Choo via GitGitGadget, Jun 26, 2023
  100. Junio C HamanoJun 26, 2023
  101. 00/11 config: remove global state from config iterationGlen Choo via GitGitGadget, Jun 28, 2023
  102. 01/11 config: inline git_color_default_configGlen Choo via GitGitGadget, Jun 28, 2023
  103. 02/11 urlmatch.h: use config_fn_t typeGlen Choo via GitGitGadget, Jun 28, 2023
  104. 04/11 config.c: pass ctx in configsetsGlen Choo via GitGitGadget, Jun 28, 2023
  105. 05/11 config: pass ctx with config filesGlen Choo via GitGitGadget, Jun 28, 2023
  106. 06/11 config.c: pass ctx with CLI configGlen Choo via GitGitGadget, Jun 28, 2023
  107. 07/11 trace2: plumb config kviGlen Choo via GitGitGadget, Jun 28, 2023
  108. 03/11 config: add ctx arg to config_fn_tGlen Choo via GitGitGadget, Jun 28, 2023
  109. 09/11 config.c: remove config_reader from configsetsGlen Choo via GitGitGadget, Jun 28, 2023
  110. 10/11 config: add kvi.path, use it to evaluate includesGlen Choo via GitGitGadget, Jun 28, 2023
  111. 11/11 config: pass source to config_parser_event_fn_tGlen Choo via GitGitGadget, Jun 28, 2023
  112. 08/11 config: pass kvi to die_bad_number()Glen Choo via GitGitGadget, Jun 28, 2023
  113. Jonathan TanJun 28, 2023
  114. Junio C HamanoJun 28, 2023
  115. Phillip WoodJul 11, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.