log: decorate grafted commits with "grafted"
In shallow repositories, this may help detect whether a branch ends, or it is deeper than current depth. It also show graft points that extend a branch. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Aug 18, 2011 at 19:29 UTC
76f5df305beddb864b3d1d12800d0de442d05596
1 file changed
+12
log-tree.c
+12
@@ -18,6 +18,7 @@ enum decoration_type {
18
DECORATION_REF_TAG,
19
DECORATION_REF_STASH,
20
DECORATION_REF_HEAD,
21
+ DECORATION_GRAFTED,
22
};
23
24
static char decoration_colors[][COLOR_MAXLEN] = {
@@ -27,6 +28,7 @@ static char decoration_colors[][COLOR_MAXLEN] = {
28
GIT_COLOR_BOLD_YELLOW, /* REF_TAG */
29
GIT_COLOR_BOLD_MAGENTA, /* REF_STASH */
30
GIT_COLOR_BOLD_CYAN, /* REF_HEAD */
31
+ GIT_COLOR_BOLD_BLUE, /* GRAFTED */
32
};
33
34
static const char *decorate_get_color(int decorate_use_color, enum decoration_type ix)
@@ -118,6 +120,15 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
120
return 0;
121
}
122
123
+static int add_graft_decoration(const struct commit_graft *graft, void *cb_data)
124
+{
125
+ struct commit *commit = lookup_commit(graft->sha1);
126
+ if (!commit)
127
+ return 0;
128
+ add_name_decoration(DECORATION_GRAFTED, "grafted", &commit->object);
129
+ return 0;
130
+}
131
+
132
void load_ref_decorations(int flags)
133
{
134
static int loaded;
@@ -125,6 +136,7 @@ void load_ref_decorations(int flags)
136
loaded = 1;
137
for_each_ref(add_ref_decoration, &flags);
138
head_ref(add_ref_decoration, &flags);
139
+ for_each_commit_graft(add_graft_decoration, NULL);
140
}
141
}
142