Skip to content

Commit 23900a9

Browse files
committed
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 <[email protected]>
1 parent d249b09 commit 23900a9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

wt-status.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "cache.h"
22
#include "wt-status.h"
3-
#include "color.h"
43
#include "object.h"
54
#include "dir.h"
65
#include "commit.h"
@@ -11,7 +10,7 @@
1110
#include "run-command.h"
1211
#include "remote.h"
1312

14-
static char wt_status_colors[][COLOR_MAXLEN] = {
13+
static char default_wt_status_colors[][COLOR_MAXLEN] = {
1514
GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
1615
GIT_COLOR_GREEN, /* WT_STATUS_UPDATED */
1716
GIT_COLOR_RED, /* WT_STATUS_CHANGED */
@@ -40,7 +39,7 @@ static int parse_status_slot(const char *var, int offset)
4039

4140
static const char *color(int slot, struct wt_status *s)
4241
{
43-
return s->use_color > 0 ? wt_status_colors[slot] : "";
42+
return s->use_color > 0 ? s->color_palette[slot] : "";
4443
}
4544

4645
void wt_status_prepare(struct wt_status *s)
@@ -49,6 +48,8 @@ void wt_status_prepare(struct wt_status *s)
4948
const char *head;
5049

5150
memset(s, 0, sizeof(*s));
51+
memcpy(s->color_palette, default_wt_status_colors,
52+
sizeof(default_wt_status_colors));
5253
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
5354
s->use_color = -1;
5455
s->relative_paths = 1;
@@ -613,7 +614,7 @@ int git_status_config(const char *k, const char *v, void *cb)
613614
int slot = parse_status_slot(k, 13);
614615
if (!v)
615616
return config_error_nonbool(k);
616-
color_parse(v, k, wt_status_colors[slot]);
617+
color_parse(v, k, s->color_palette[slot]);
617618
return 0;
618619
}
619620
if (!strcmp(k, "status.relativepaths")) {

wt-status.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
#include <stdio.h>
55
#include "string-list.h"
6+
#include "color.h"
67

78
enum color_wt_status {
8-
WT_STATUS_HEADER,
9+
WT_STATUS_HEADER = 0,
910
WT_STATUS_UPDATED,
1011
WT_STATUS_CHANGED,
1112
WT_STATUS_UNTRACKED,
@@ -37,6 +38,7 @@ struct wt_status {
3738
int relative_paths;
3839
int submodule_summary;
3940
enum untracked_status_type show_untracked_files;
41+
char color_palette[WT_STATUS_UNMERGED+1][COLOR_MAXLEN];
4042

4143
/* These are computed during processing of the individual sections */
4244
int commitable;

0 commit comments

Comments
 (0)