Skip to content

Commit

Permalink
wt-status: move wt_status_colors[] into wt_status structure
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Aug 10, 2009
1 parent d249b09 commit 23900a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions wt-status.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "cache.h"
#include "wt-status.h"
#include "color.h"
#include "object.h"
#include "dir.h"
#include "commit.h"
Expand All @@ -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 */
Expand Down Expand Up @@ -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->use_color > 0 ? wt_status_colors[slot] : "";
return s->use_color > 0 ? s->color_palette[slot] : "";
}

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

memset(s, 0, sizeof(*s));
memcpy(s->color_palette, default_wt_status_colors,
sizeof(default_wt_status_colors));
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
s->use_color = -1;
s->relative_paths = 1;
Expand Down Expand Up @@ -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->color_palette[slot]);
return 0;
}
if (!strcmp(k, "status.relativepaths")) {
Expand Down
4 changes: 3 additions & 1 deletion wt-status.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

#include <stdio.h>
#include "string-list.h"
#include "color.h"

enum color_wt_status {
WT_STATUS_HEADER,
WT_STATUS_HEADER = 0,
WT_STATUS_UPDATED,
WT_STATUS_CHANGED,
WT_STATUS_UNTRACKED,
Expand Down Expand Up @@ -37,6 +38,7 @@ struct wt_status {
int relative_paths;
int submodule_summary;
enum untracked_status_type show_untracked_files;
char color_palette[WT_STATUS_UNMERGED+1][COLOR_MAXLEN];

/* These are computed during processing of the individual sections */
int commitable;
Expand Down

0 comments on commit 23900a9

Please sign in to comment.