summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 485cdb9)
raw | patch | inline | side by side (parent: 485cdb9)
author | Dan McGee <dpmcgee@gmail.com> | |
Tue, 5 Apr 2011 05:40:23 +0000 (00:40 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 5 Apr 2011 06:20:39 +0000 (23:20 -0700) |
This also adds the new colors to show-branch that were added a while
back for graph output.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
back for graph output.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/show-branch.c | patch | blob | history | |
color.c | patch | blob | history | |
color.h | patch | blob | history | |
graph.c | patch | blob | history |
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index da695815e26c281cbacfbf865dfa72da44df9f19..1abcd9e02e64022e2619db3de40c7b3a731d4479 100644 (file)
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
};
static int showbranch_use_color = -1;
-static char column_colors[][COLOR_MAXLEN] = {
- GIT_COLOR_RED,
- GIT_COLOR_GREEN,
- GIT_COLOR_YELLOW,
- GIT_COLOR_BLUE,
- GIT_COLOR_MAGENTA,
- GIT_COLOR_CYAN,
-};
-
-#define COLUMN_COLORS_MAX (ARRAY_SIZE(column_colors))
static int default_num;
static int default_alloc;
static const char *get_color_code(int idx)
{
if (showbranch_use_color)
- return column_colors[idx];
+ return column_colors_ansi[idx % column_colors_ansi_max];
return "";
}
for (j = 0; j < i; j++)
putchar(' ');
printf("%s%c%s [%s] ",
- get_color_code(i % COLUMN_COLORS_MAX),
+ get_color_code(i),
is_head ? '*' : '!',
get_color_reset_code(), ref_name[i]);
}
else
mark = '+';
printf("%s%c%s",
- get_color_code(i % COLUMN_COLORS_MAX),
+ get_color_code(i),
mark, get_color_reset_code());
}
putchar(' ');
index 417cf8fb2812b09ad4f5bfa2674b35d7e11f32b9..3db214c24720496f13481b718e46810c21f53b8d 100644 (file)
--- a/color.c
+++ b/color.c
int git_use_color_default = 0;
+/*
+ * The list of available column colors.
+ */
+const char *column_colors_ansi[] = {
+ GIT_COLOR_RED,
+ GIT_COLOR_GREEN,
+ GIT_COLOR_YELLOW,
+ GIT_COLOR_BLUE,
+ GIT_COLOR_MAGENTA,
+ GIT_COLOR_CYAN,
+ GIT_COLOR_BOLD_RED,
+ GIT_COLOR_BOLD_GREEN,
+ GIT_COLOR_BOLD_YELLOW,
+ GIT_COLOR_BOLD_BLUE,
+ GIT_COLOR_BOLD_MAGENTA,
+ GIT_COLOR_BOLD_CYAN,
+ GIT_COLOR_RESET,
+};
+
+/* Ignore the RESET at the end when giving the size */
+const int column_colors_ansi_max = ARRAY_SIZE(column_colors_ansi) - 1;
+
static int parse_color(const char *name, int len)
{
static const char * const color_names[] = {
index c0528cf08713ac8e101cfdeac2b3de193a0c5094..68a926a2cdfb870ae0da0bfbc4c5b36681609911 100644 (file)
--- a/color.h
+++ b/color.h
*/
extern int git_use_color_default;
+/* A default list of colors to use for commit graphs and show-branch output */
+extern const char *column_colors_ansi[];
+extern const int column_colors_ansi_max;
/*
* Use this instead of git_default_config if you need the value of color.ui.
index ef2e24e85a41dc97cf00bb7b19985ec01b8662bf..2f6893dc4f97dfbccad6f22f66861c24021a3c46 100644 (file)
--- a/graph.c
+++ b/graph.c
GRAPH_COLLAPSING
};
-/*
- * The list of available column colors.
- */
-static const char *column_colors_ansi[] = {
- GIT_COLOR_RED,
- GIT_COLOR_GREEN,
- GIT_COLOR_YELLOW,
- GIT_COLOR_BLUE,
- GIT_COLOR_MAGENTA,
- GIT_COLOR_CYAN,
- GIT_COLOR_BOLD_RED,
- GIT_COLOR_BOLD_GREEN,
- GIT_COLOR_BOLD_YELLOW,
- GIT_COLOR_BOLD_BLUE,
- GIT_COLOR_BOLD_MAGENTA,
- GIT_COLOR_BOLD_CYAN,
- GIT_COLOR_RESET,
-};
-
-#define COLUMN_COLORS_ANSI_MAX (ARRAY_SIZE(column_colors_ansi) - 1)
-
static const char **column_colors;
static unsigned short column_colors_max;
if (!column_colors)
graph_set_column_colors(column_colors_ansi,
- COLUMN_COLORS_ANSI_MAX);
+ column_colors_ansi_max);
graph->commit = NULL;
graph->revs = opt;