[PATCH 3/4] status and commit: Use color configuration infrastructure
From: Matthias Kestenholz <matthias@spinlock.ch>
Signed-off-by: Matthias Kestenholz <matthias@spinlock.ch>
---
builtin-commit.c | 8 +++++---
wt-status.c | 7 +++----
wt-status.h | 1 -
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 73f1e35..e442b5f 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -7,6 +7,7 @@
#include "cache.h"
#include "cache-tree.h"
+#include "color.h"
#include "dir.h"
#include "builtin.h"
#include "diff.h"
@@ -435,10 +436,10 @@ static int prepare_log_message(const char *index_file, const char *prefix)
if (only_include_assumed)
fprintf(fp, "# %s\n", only_include_assumed);
- saved_color_setting = wt_status_use_color;
- wt_status_use_color = 0;
+ saved_color_setting = git_use_color;
+ git_use_color = 0;
commitable = run_status(fp, index_file, prefix, 1);
- wt_status_use_color = saved_color_setting;
+ git_use_color = saved_color_setting;
fclose(fp);
@@ -639,6 +640,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
int commitable;
git_config(git_status_config);
+ git_color_config();
argc = parse_and_validate_options(argc, argv, builtin_status_usage);
diff --git a/wt-status.c b/wt-status.c
index c0c2472..ebcbe5a 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -9,7 +9,6 @@
#include "diffcore.h"
int wt_status_relative_paths = 1;
-int wt_status_use_color = 0;
static char wt_status_colors[][COLOR_MAXLEN] = {
"", /* WT_STATUS_HEADER: normal */
"\033[32m", /* WT_STATUS_UPDATED: green */
@@ -40,7 +39,7 @@ static int parse_status_slot(const char *var, int offset)
static const char* color(int slot)
{
- return wt_status_use_color ? wt_status_colors[slot] : "";
+ return git_use_color > 0 ? wt_status_colors[slot] : "";
}
void wt_status_prepare(struct wt_status *s)
@@ -397,7 +396,7 @@ void wt_status_print(struct wt_status *s)
int git_status_config(const char *k, const char *v)
{
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
- wt_status_use_color = git_config_colorbool(k, v, -1);
+ git_use_color = git_config_colorbool(k, v, -1);
return 0;
}
if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
@@ -409,5 +408,5 @@ int git_status_config(const char *k, const char *v)
wt_status_relative_paths = git_config_bool(k, v);
return 0;
}
- return git_default_config(k, v);
+ return git_color_default_config(k, v);
}
diff --git a/wt-status.h b/wt-status.h
index 02afaa6..05b05ba 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -28,7 +28,6 @@ struct wt_status {
};
int git_status_config(const char *var, const char *value);
-int wt_status_use_color;
int wt_status_relative_paths;
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
--
1.5.4.rc2.1104.gec8ae5-dirty