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

Re: [PATCH v2] make color.ui default to 'auto'

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
May 15, 2013, 16:52 UTC
Message-ID
<vpq61ykfang.fsf@grenoble-inp.fr>
In-Reply-To
<7vtxm4cjil.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>
>> diff --git a/builtin/config.c b/builtin/config.c
>> index 000d27c..ecfceca 100644
>> --- a/builtin/config.c
>> +++ b/builtin/config.c
>> @@ -316,7 +316,7 @@ static void get_color(const char *def_color)
>>  
>>  static int get_colorbool_found;
>>  static int get_diff_color_found;
>> -static int get_color_ui_found;
>> +static int get_color_ui_found = GIT_COLOR_AUTO;
>
> It is curious to notice that we have these three and only one is
> initialized to the new default value, while the other two get -1
> at the beginning of get_colorbool().

Right. The meaning of the _found suffix is clear for the first two, but not the last.

> I wonder if it would be cleaner to statically initialize all three
> to -1 here, drop the assignment of -1 to two of them from the
> beginning of get_colorbool(), and then have a final fallback inside
> the want_color() call itself, i.e.

I've left the assignments within the function (I like the initialisation right before usage, I don't have to worry about how many times the function is called then), but I've added a patch that initializes get_color_ui_found to -1 like the others, and does essentially this:

> 	get_colorbool_found = want_color(get_colorbool_found < 0
>         				? GIT_COLOR_AUTO
>                                         : get_colorbool_found);

Except I've made it a separate if statement. Then PATCH 2/2 is really crystal clear.

Reroll comming, with an improved commit message that should adress the points in the other message.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Junio C HamanoNext: Matthieu Moy
Message 12 of 27 in “is this a bug of git-diff?”
  1. eric liouMay 15, 2013
  2. Antoine PelisseMay 15, 2013
  3. Antoine PelisseMay 15, 2013
  4. Matthieu MoyMay 15, 2013
  5. John KeepingMay 15, 2013
  6. Default for color.ui (was Re: is this a bug of git-diff?)Matthieu Moy, May 15, 2013
  7. Felipe ContrerasMay 15, 2013
  8. make color.ui default to 'auto'Matthieu Moy, May 15, 2013
  9. Johan HerlandMay 15, 2013
  10. make color.ui default to 'auto'Matthieu Moy, May 15, 2013
  11. Junio C HamanoMay 15, 2013
  12. Matthieu MoyMay 15, 2013
  13. 1/2 config: refactor management of color.ui's default valueMatthieu Moy, May 15, 2013
  14. 2/2 make color.ui default to 'auto'Matthieu Moy, May 15, 2013
  15. Junio C HamanoMay 15, 2013
  16. Stefano LattariniMay 15, 2013
  17. make color.ui default to 'auto'Matthieu Moy, May 15, 2013
  18. Junio C HamanoMay 15, 2013
  19. Matthieu MoyMay 15, 2013
  20. Junio C HamanoMay 15, 2013
  21. Matthieu MoyMay 15, 2013
  22. Junio C HamanoMay 15, 2013
  23. Matthieu MoyMay 15, 2013
  24. Junio C HamanoMay 15, 2013
  25. Felipe ContrerasMay 15, 2013
  26. John KeepingMay 15, 2013
  27. Mike HommeyMay 15, 2013

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.