summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3e1dd17)
raw | patch | inline | side by side (parent: 3e1dd17)
author | Jeff King <peff@peff.net> | |
Thu, 18 Aug 2011 05:05:35 +0000 (22:05 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 19 Aug 2011 22:51:38 +0000 (15:51 -0700) |
All of the "do we want color" flags default to -1 to
indicate that we don't have any color configured. This value
is handled in one of two ways:
1. In porcelain, we check early on whether the value is
still -1 after reading the config, and set it to the
value of color.ui (which defaults to 0).
2. In plumbing, it stays untouched as -1, and want_color
defaults it to off.
This works fine, but means that every porcelain has to check
and reassign its color flag. Now that want_color gives us a
place to put this check in a single spot, we can do that,
simplifying the calling code.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
indicate that we don't have any color configured. This value
is handled in one of two ways:
1. In porcelain, we check early on whether the value is
still -1 after reading the config, and set it to the
value of color.ui (which defaults to 0).
2. In plumbing, it stays untouched as -1, and want_color
defaults it to off.
This works fine, but means that every porcelain has to check
and reassign its color flag. Now that want_color gives us a
place to put this check in a single spot, we can do that,
simplifying the calling code.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c | patch | blob | history | |
builtin/commit.c | patch | blob | history | |
builtin/diff.c | patch | blob | history | |
builtin/grep.c | patch | blob | history | |
builtin/log.c | patch | blob | history | |
builtin/merge.c | patch | blob | history | |
builtin/show-branch.c | patch | blob | history | |
color.c | patch | blob | history | |
color.h | patch | blob | history |
diff --git a/builtin/branch.c b/builtin/branch.c
index d6d3c7d85bcb1626a4bdee29f03b6b812e0c017a..73d41700d164081a2224f88a74fe3260ed45c9a9 100644 (file)
--- a/builtin/branch.c
+++ b/builtin/branch.c
git_config(git_branch_config, NULL);
- if (branch_use_color == -1)
- branch_use_color = git_use_color_default;
-
track = git_branch_track;
head = resolve_ref("HEAD", head_sha1, 0, NULL);
diff --git a/builtin/commit.c b/builtin/commit.c
index 295803a265fbf04345af6b98af8f28873735143f..9763146b6f224b32e56d3d67b0750b56a989b6cf 100644 (file)
--- a/builtin/commit.c
+++ b/builtin/commit.c
if (s.relative_paths)
s.prefix = prefix;
- if (s.use_color == -1)
- s.use_color = git_use_color_default;
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
switch (status_format) {
case STATUS_FORMAT_SHORT:
git_config(git_commit_config, &s);
determine_whence(&s);
- if (s.use_color == -1)
- s.use_color = git_use_color_default;
argc = parse_and_validate_options(argc, argv, builtin_commit_usage,
prefix, &s);
- if (dry_run) {
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
+ if (dry_run)
return dry_run_commit(argc, argv, prefix, &s);
- }
index_file = prepare_index(argc, argv, prefix, 0);
/* Set up everything for writing the commit object. This includes
diff --git a/builtin/diff.c b/builtin/diff.c
index 69cd5eed78cb402839813e7eca65b5598afa4a90..1118689fb246b864ce758039543327c4304cdaa4 100644 (file)
--- a/builtin/diff.c
+++ b/builtin/diff.c
gitmodules_config();
git_config(git_diff_ui_config, NULL);
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
-
init_revisions(&rev, prefix);
/* If this is a no-index diff, just run it and exit there. */
diff --git a/builtin/grep.c b/builtin/grep.c
index c17d7de562d1903fdd5ed8736d05014fec4e9f4a..18522cab75cab30fcacb6b259e5bfe9125e0d9c9 100644 (file)
--- a/builtin/grep.c
+++ b/builtin/grep.c
strcpy(opt.color_sep, GIT_COLOR_CYAN);
opt.color = -1;
git_config(grep_config, &opt);
- if (opt.color == -1)
- opt.color = git_use_color_default;
/*
* If there is no -- then the paths must exist in the working
diff --git a/builtin/log.c b/builtin/log.c
index 5c2af590047d92554d87acc5d7113a2f1f730a96..d760ee0885763e964afd9cdaf09a0986da606804 100644 (file)
--- a/builtin/log.c
+++ b/builtin/log.c
git_config(git_log_config, NULL);
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
-
init_revisions(&rev, prefix);
rev.diff = 1;
rev.simplify_history = 0;
git_config(git_log_config, NULL);
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
-
init_pathspec(&match_all, NULL);
init_revisions(&rev, prefix);
rev.diff = 1;
git_config(git_log_config, NULL);
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
-
init_revisions(&rev, prefix);
init_reflog_walk(&rev.reflog_info);
rev.verbose_header = 1;
git_config(git_log_config, NULL);
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
-
init_revisions(&rev, prefix);
rev.always_show_header = 1;
memset(&opt, 0, sizeof(opt));
diff --git a/builtin/merge.c b/builtin/merge.c
index 7209edf76af7f43e1e1de149e736c50d6c84c114..b75ae0193cb04e969b9d32adfa8a47da3fd956fd 100644 (file)
--- a/builtin/merge.c
+++ b/builtin/merge.c
git_config(git_merge_config, NULL);
- /* for color.ui */
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
-
if (branch_mergeoptions)
parse_branch_merge_options(branch_mergeoptions);
argc = parse_options(argc, argv, prefix, builtin_merge_options,
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 4b726fabde153ad0e203e986a9070cf144f1cbaf..4b480d7c7ca6c6258a5cd82cfc88df62cd0d218f 100644 (file)
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
git_config(git_show_branch_config, NULL);
- if (showbranch_use_color == -1)
- showbranch_use_color = git_use_color_default;
-
/* If nothing is specified, try the default first */
if (ac == 1 && default_num) {
ac = default_num;
index ec96fe1045390b2c10fc989ea17d9c6e7ecea781..e8e26818b3b1f2ffce1374e2edf88b40c575c3dd 100644 (file)
--- a/color.c
+++ b/color.c
#include "cache.h"
#include "color.h"
-int git_use_color_default = 0;
+static int git_use_color_default = 0;
int color_stdout_is_tty = -1;
/*
{
static int want_auto = -1;
+ if (var < 0)
+ var = git_use_color_default;
+
if (var == GIT_COLOR_AUTO) {
if (want_auto < 0)
want_auto = check_auto_color();
return want_auto;
}
- return var > 0;
+ return var;
}
int git_color_config(const char *var, const char *value, void *cb)
index 3e515f2a46004b2f36851c1a8d2fcc03a092c682..9a8495bb7ff06eb4e94e190d902b48c23fc021f9 100644 (file)
--- a/color.h
+++ b/color.h
#define GIT_COLOR_ALWAYS 1
#define GIT_COLOR_AUTO 2
-/*
- * This variable stores the value of color.ui
- */
-extern int git_use_color_default;
-
/* A default list of colors to use for commit graphs and show-branch output */
extern const char *column_colors_ansi[];
extern const int column_colors_ansi_max;