@matheusbsbs / matheus-bagliano / commits / 23900a9646
Fork 0

wt-status: move wt_status_colors[] into wt_status structure

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 the libification started by the previous commit. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 9, 2009 at 23:08 UTC 23900a964608bbfda6989a0a2cd4342f19f9194c
2 files changed +8 -5
wt-status.c
+5 -4
@@ -1,6 +1,5 @@
1 #include "cache.h"
2 #include "wt-status.h"
3 -#include "color.h"
3 #include "object.h"
4 #include "dir.h"
5 #include "commit.h"
@@ -11,7 +10,7 @@
10 #include "run-command.h"
11 #include "remote.h"
12
14 -static char wt_status_colors[][COLOR_MAXLEN] = {
13 +static char default_wt_status_colors[][COLOR_MAXLEN] = {
14 GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
15 GIT_COLOR_GREEN, /* WT_STATUS_UPDATED */
16 GIT_COLOR_RED, /* WT_STATUS_CHANGED */
@@ -40,7 +39,7 @@ static int parse_status_slot(const char *var, int offset)
39
40 static const char *color(int slot, struct wt_status *s)
41 {
43 - return s->use_color > 0 ? wt_status_colors[slot] : "";
42 + return s->use_color > 0 ? s->color_palette[slot] : "";
43 }
44
45 void wt_status_prepare(struct wt_status *s)
@@ -49,6 +48,8 @@ void wt_status_prepare(struct wt_status *s)
48 const char *head;
49
50 memset(s, 0, sizeof(*s));
51 + memcpy(s->color_palette, default_wt_status_colors,
52 + sizeof(default_wt_status_colors));
53 s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
54 s->use_color = -1;
55 s->relative_paths = 1;
@@ -613,7 +614,7 @@ int git_status_config(const char *k, const char *v, void *cb)
614 int slot = parse_status_slot(k, 13);
615 if (!v)
616 return config_error_nonbool(k);
616 - color_parse(v, k, wt_status_colors[slot]);
617 + color_parse(v, k, s->color_palette[slot]);
618 return 0;
619 }
620 if (!strcmp(k, "status.relativepaths")) {
wt-status.h
+3 -1
@@ -3,9 +3,10 @@
3
4 #include <stdio.h>
5 #include "string-list.h"
6 +#include "color.h"
7
8 enum color_wt_status {
8 - WT_STATUS_HEADER,
9 + WT_STATUS_HEADER = 0,
10 WT_STATUS_UPDATED,
11 WT_STATUS_CHANGED,
12 WT_STATUS_UNTRACKED,
@@ -37,6 +38,7 @@ struct wt_status {
38 int relative_paths;
39 int submodule_summary;
40 enum untracked_status_type show_untracked_files;
41 + char color_palette[WT_STATUS_UNMERGED+1][COLOR_MAXLEN];
42
43 /* These are computed during processing of the individual sections */
44 int commitable;