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

Re: [PATCHv3 1/4] color.h: document and modernize header

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 8, 2018, 19:14 UTC
Message-ID
<xmqqr2r088p3.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20180104224007.214548-2-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 9 quoted lines
>  /*
> - * Set the color buffer (which must be COLOR_MAXLEN bytes)
> - * to the raw color bytes; this is useful for initializing
> - * default color variables.
> + * NEEDSWWORK: document this function or refactor grep.c to stop using this
> + * function.
>   */
> -void color_set(char *dst, const char *color_bytes);
> +extern void color_set(char *dst, const char *color_bytes);

The original that is removed by the patch documents the function well enough; as long as the NEEDSWORK comment is followed through in a later step in the series, it's alright, though ;-)

Show 12 quoted lines
> -int git_config_colorbool(const char *var, const char *value);
> -int want_color(int var);
> -int color_parse(const char *value, char *dst);
> -int color_parse_mem(const char *value, int len, char *dst);
> +/*
> + * Parse a config option, which can be a boolean or one of
> + * "never", "auto", "always". Return a constant of
> + * GIT_COLOR_NEVER for "never" or negative boolean,
> + * GIT_COLOR_ALWAYS for "always" or a positive boolean,
> + * and GIT_COLOR_AUTO for "auto".
> + */
> +extern int git_config_colorbool(const char *var, const char *value);

"never" and "always" not being part of usual boolean vocabulary makes it a bit awkward to explain.

Show 7 quoted lines
> +/*
> + * Output the formatted string in the specified color (and then reset to normal
> + * color so subsequent output is uncolored). Omits the color encapsulation if
> + * `color` is NULL. The `color_fprintf_ln` prints a new line after resetting
> + * the color. The `color_print_strbuf` prints the given pre-formatted strbuf
> + * instead, up to its first NUL character.
> + */

Obviously, it does not have to be part of this step nor series, but the above observation makes us realize that color_print_strbuf() would probably be an unreasonably narrow interface. It is not too much to ask the caller to dereference and pass only the .buf component of the strbuf to an alternative helper that takes "const char *" and by doing so would allow us to let other callers that do not have a strbuf but just a plain string use it, too.

Looks good.
Previous: Stefan BellerNext: Stefan Beller
Message 8 of 17 in “blame: (dim rep. metadata lines or fields, decay date coloring)”
  1. 0/4 blame: (dim rep. metadata lines or fields, decay date coloring)Stefan Beller, Nov 10, 2017
  2. 1/4 color.h: modernize headerStefan Beller, Nov 10, 2017
  3. 2/4 builtin/blame: dim uninteresting metadataStefan Beller, Nov 10, 2017
  4. 3/4 builtin/blame: add option to color metadata fields separatelyStefan Beller, Nov 10, 2017
  5. 4/4 builtin/blame: highlight recently changed linesStefan Beller, Nov 10, 2017
  6. 0/4 blame: (dim rep. metadata lines or fields, decay date coloring)Stefan Beller, Jan 4, 2018
  7. 1/4 color.h: document and modernize headerStefan Beller, Jan 4, 2018
  8. Junio C HamanoJan 8, 2018
  9. 2/4 builtin/blame: dim uninteresting metadataStefan Beller, Jan 4, 2018
  10. Junio C HamanoJan 8, 2018
  11. Stefan BellerFeb 8, 2018
  12. 4/4 builtin/blame: highlight recently changed linesStefan Beller, Jan 4, 2018
  13. Junio C HamanoJan 8, 2018
  14. Stefan BellerJan 8, 2018
  15. 3/4 builtin/blame: add option to color metadata fields separatelyStefan Beller, Jan 4, 2018
  16. Ævar Arnfjörð BjarmasonFeb 1, 2018
  17. Stefan BellerFeb 1, 2018

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.