mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
color: use GIT_COLOR_* instead of numeric constants
Long ago Git's decision to show color for a subsytem was stored in a
tri-state variable: it could be true (1), false (0), or unknown (-1).
But since daa0c3d971 (color: delay auto-color decision until point of
use, 2011-08-17) we want to carry around a new state, "auto", which
bases the decision on the tty-ness of stdout (rather than collapsing
that "auto" state to a true/false immediately).
That commit introduced a set of GIT_COLOR_* defines to represent each
state: UNKNOWN, ALWAYS, NEVER, and AUTO. But it only used the AUTO
value, and left alone code using bare 0/1/-1 values. And of course since
then we've grown many new spots that use those bare values.
Let's switch all of these to use the named constants. That should make
the code a bit easier to read, as it is more obvious that we're
representing a color decision.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
e335ff31f7
commit
3c3e9b8303
@@ -148,7 +148,7 @@ void wt_status_prepare(struct repository *r, struct wt_status *s)
|
||||
memcpy(s->color_palette, default_wt_status_colors,
|
||||
sizeof(default_wt_status_colors));
|
||||
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
|
||||
s->use_color = -1;
|
||||
s->use_color = GIT_COLOR_UNKNOWN;
|
||||
s->relative_paths = 1;
|
||||
s->branch = refs_resolve_refdup(get_main_ref_store(the_repository),
|
||||
"HEAD", 0, NULL, NULL);
|
||||
@@ -1164,7 +1164,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s)
|
||||
* before.
|
||||
*/
|
||||
if (s->fp != stdout) {
|
||||
rev.diffopt.use_color = 0;
|
||||
rev.diffopt.use_color = GIT_COLOR_NEVER;
|
||||
wt_status_add_cut_line(s);
|
||||
}
|
||||
if (s->verbose > 1 && s->committable) {
|
||||
@@ -2164,7 +2164,7 @@ static void wt_shortstatus_print(struct wt_status *s)
|
||||
|
||||
static void wt_porcelain_print(struct wt_status *s)
|
||||
{
|
||||
s->use_color = 0;
|
||||
s->use_color = GIT_COLOR_NEVER;
|
||||
s->relative_paths = 0;
|
||||
s->prefix = NULL;
|
||||
s->no_gettext = 1;
|
||||
|
||||
Reference in New Issue
Block a user