Re: [PATCH 07/10] color: delay auto-color decision until point of use
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 18, 2011, 21:59 UTC
- Message-ID
- <7vvctu7402.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20110818050421.GG2889@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 16 quoted lines
> diff --git a/color.h b/color.h > index a190a25..d715fd5 100644 > --- a/color.h > +++ b/color.h > @@ -49,6 +49,16 @@ struct strbuf; > #define GIT_COLOR_NIL "NIL" > > /* > + * The first three are chosen to match common usage in the code, and what is > + * returned from git_config_colorbool. The "auto" value can be returned from > + * config_colorbool, and will be converted by want_color() into either 0 or 1. > + */ > +#define GIT_COLOR_UNKNOWN -1 > +#define GIT_COLOR_ALWAYS 0 > +#define GIT_COLOR_NEVER 1 > +#define GIT_COLOR_AUTO 2
The ALWAYS/NEVER somehow go against my intuition. Let me trace one codepath starting from git_branch_config().
branch_use_color is set from git_config_colorbool("color.branch");
-> given "never", git_config_colorbool() returns 0;
branch_get_color() asks want_color(branch_use_color);
-> want_color() returns if the given value is positive.Because git_config_colorbool() does not use the above symbolic constants, everything goes well, but aren't these two swapped?