summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--color.c5
-rw-r--r--color.h5
-rw-r--r--wt-status.c7
3 files changed, 15 insertions, 2 deletions
diff --git a/color.c b/color.c
index 1b00554..6a5a54e 100644
--- a/color.c
+++ b/color.c
@@ -211,3 +211,8 @@ int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...)
va_end(args);
return r;
}
+
+int color_is_nil(const char *c)
+{
+ return !strcmp(c, "NIL");
+}
diff --git a/color.h b/color.h
index 03ca064..170ff40 100644
--- a/color.h
+++ b/color.h
@@ -43,6 +43,9 @@
#define GIT_COLOR_BG_MAGENTA "\033[45m"
#define GIT_COLOR_BG_CYAN "\033[46m"
+/* A special value meaning "no color selected" */
+#define GIT_COLOR_NIL "NIL"
+
/*
* This variable stores the value of color.ui
*/
@@ -62,4 +65,6 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
__attribute__((format (printf, 3, 4)))
int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
+int color_is_nil(const char *color);
+
#endif /* COLOR_H */
diff --git a/wt-status.c b/wt-status.c
index 19c9cb1..ffe86b9 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -21,12 +21,15 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {
GIT_COLOR_RED, /* WT_STATUS_UNMERGED */
GIT_COLOR_GREEN, /* WT_STATUS_LOCAL_BRANCH */
GIT_COLOR_RED, /* WT_STATUS_REMOTE_BRANCH */
- GIT_COLOR_NORMAL, /* WT_STATUS_ONBRANCH */
+ GIT_COLOR_NIL, /* WT_STATUS_ONBRANCH */
};
static const char *color(int slot, struct wt_status *s)
{
- return s->use_color > 0 ? s->color_palette[slot] : "";
+ const char *c = s->use_color > 0 ? s->color_palette[slot] : "";
+ if (slot == WT_STATUS_ONBRANCH && color_is_nil(c))
+ c = s->color_palette[WT_STATUS_HEADER];
+ return c;
}
void wt_status_prepare(struct wt_status *s)