summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a752412)
raw | patch | inline | side by side (parent: a752412)
author | Nazri Ramliy <ayiehere@gmail.com> | |
Sat, 19 Jun 2010 01:37:35 +0000 (09:37 +0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 21 Jun 2010 04:44:32 +0000 (21:44 -0700) |
This makes the decorations stand out more and easier to distinguish
and spot because they are colored differently depending on their type.
Signed-off-by: Nazri Ramliy <ayiehere@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
and spot because they are colored differently depending on their type.
Signed-off-by: Nazri Ramliy <ayiehere@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
log-tree.c | patch | blob | history |
diff --git a/log-tree.c b/log-tree.c
index bec609676e1cee18d25b3158ac3049e886e19860..61680f4664e5be109b9e1471ea18ee1818f2f9c9 100644 (file)
--- a/log-tree.c
+++ b/log-tree.c
#include "reflog-walk.h"
#include "refs.h"
#include "string-list.h"
+#include "color.h"
struct decoration name_decoration = { "object names" };
DECORATION_REF_HEAD,
};
+static char decoration_colors[][COLOR_MAXLEN] = {
+ GIT_COLOR_RESET,
+ GIT_COLOR_BOLD_GREEN, /* REF_LOCAL */
+ GIT_COLOR_BOLD_RED, /* REF_REMOTE */
+ GIT_COLOR_BOLD_YELLOW, /* REF_TAG */
+ GIT_COLOR_BOLD_MAGENTA, /* REF_STASH */
+ GIT_COLOR_BOLD_CYAN, /* REF_HEAD */
+};
+
+static const char *decorate_get_color(int decorate_use_color, enum decoration_type ix)
+{
+ if (decorate_use_color)
+ return decoration_colors[ix];
+ return "";
+}
+
+/*
+ * log-tree.c uses DIFF_OPT_TST for determining whether to use color
+ * for showing the commit sha1, use the same check for --decorate
+ */
+#define decorate_get_color_opt(o, ix) \
+ decorate_get_color(DIFF_OPT_TST((o), COLOR_DIFF), ix)
+
static void add_name_decoration(enum decoration_type type, const char *name, struct object *obj)
{
int nlen = strlen(name);
{
const char *prefix;
struct name_decoration *decoration;
+ const char *color_commit =
+ diff_get_color_opt(&opt->diffopt, DIFF_COMMIT);
+ const char *color_reset =
+ decorate_get_color_opt(&opt->diffopt, DECORATION_NONE);
if (opt->show_source && commit->util)
printf("\t%s", (char *) commit->util);
prefix = " (";
while (decoration) {
printf("%s", prefix);
+ fputs(decorate_get_color_opt(&opt->diffopt, decoration->type),
+ stdout);
if (decoration->type == DECORATION_REF_TAG)
- printf("tag: ");
+ fputs("tag: ", stdout);
printf("%s", decoration->name);
+ fputs(color_reset, stdout);
+ fputs(color_commit, stdout);
prefix = ", ";
decoration = decoration->next;
}