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

[PATCH 3/4] status and commit: Use color configuration infrastructure

From
Matthias Kestenholz <mk@spinlock.ch>
Date
Jan 5, 2008, 14:11 UTC
Message-ID
<1199542299-12082-3-git-send-email-mk@spinlock.ch>
In-Reply-To
<1199542299-12082-2-git-send-email-mk@spinlock.ch>
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
Previous: Matthias KestenholzNext: Matthias Kestenholz
Message 13 of 17 in “add--interactive: allow diff colors without interactive colors”
  1. add--interactive: allow diff colors without interactive colorsJeff King, Jan 4, 2008
  2. Junio C HamanoJan 5, 2008
  3. Jeff KingJan 5, 2008
  4. Junio C HamanoJan 5, 2008
  5. Jeff KingJan 5, 2008
  6. Junio C HamanoJan 5, 2008
  7. Jeff KingJan 5, 2008
  8. Matthias KestenholzJan 5, 2008
  9. Junio C HamanoJan 5, 2008
  10. Matthias KestenholzJan 5, 2008
  11. 1/4 Add infrastructure for a single color config variableMatthias Kestenholz, Jan 5, 2008
  12. 2/4 git branch: Use color configuration infrastructureMatthias Kestenholz, Jan 5, 2008
  13. 3/4 status and commit: Use color configuration infrastructureMatthias Kestenholz, Jan 5, 2008
  14. 4/4 diff and log: Use color configuration infrastructureMatthias Kestenholz, Jan 5, 2008
  15. Jeff KingJan 8, 2008
  16. Matthias KestenholzJan 8, 2008
  17. Jakub NarebskiJan 5, 2008

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.