[PATCH v3 3/8] wt-status: move wt_status_colors[] into wt_status structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The benefit of this one alone is somewhat iffy, but for completeness this
moves the wt_status_colors[] color palette to the wt_status structure to
complete what the previous commit started.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 wt-status.c |    9 +++++----
 wt-status.h |    2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index c84a18a..a2a7257 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1,6 +1,5 @@
 #include "cache.h"
 #include "wt-status.h"
-#include "color.h"
 #include "object.h"
 #include "dir.h"
 #include "commit.h"
@@ -11,7 +10,7 @@
 #include "run-command.h"
 #include "remote.h"
 
-static char wt_status_colors[][COLOR_MAXLEN] = {
+static char default_wt_status_colors[][COLOR_MAXLEN] = {
 	GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
 	GIT_COLOR_GREEN,  /* WT_STATUS_UPDATED */
 	GIT_COLOR_RED,    /* WT_STATUS_CHANGED */
@@ -40,7 +39,7 @@ static int parse_status_slot(const char *var, int offset)
 
 static const char *color(int slot, struct wt_status *s)
 {
-	return s->wt_status_use_color > 0 ? wt_status_colors[slot] : "";
+	return s->wt_status_use_color > 0 ? s->wt_status_colors[slot] : "";
 }
 
 void wt_status_prepare(struct wt_status *s)
@@ -49,6 +48,8 @@ void wt_status_prepare(struct wt_status *s)
 	const char *head;
 
 	memset(s, 0, sizeof(*s));
+	memcpy(s->wt_status_colors, default_wt_status_colors,
+	       sizeof(default_wt_status_colors));
 	s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
 	s->wt_status_use_color = -1;
 	s->wt_status_relative_paths = 1;
@@ -613,7 +614,7 @@ int git_status_config(const char *k, const char *v, void *cb)
 		int slot = parse_status_slot(k, 13);
 		if (!v)
 			return config_error_nonbool(k);
-		color_parse(v, k, wt_status_colors[slot]);
+		color_parse(v, k, s->wt_status_colors[slot]);
 		return 0;
 	}
 	if (!strcmp(k, "status.relativepaths")) {
diff --git a/wt-status.h b/wt-status.h
index 3d7fe30..f22c3c1 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -3,6 +3,7 @@
 
 #include <stdio.h>
 #include "string-list.h"
+#include "color.h"
 
 enum color_wt_status {
 	WT_STATUS_HEADER,
@@ -37,6 +38,7 @@ struct wt_status {
 	int wt_status_relative_paths;
 	int wt_status_submodule_summary;
 	enum untracked_status_type show_untracked_files;
+	char wt_status_colors[6][COLOR_MAXLEN];
 
 	/* These are computed during processing of the individual sections */
 	int commitable;
-- 
1.6.4.173.g72959

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]