Skip to content

Commit 76f5df3

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 294e15f commit 76f5df3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

log-tree.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ enum decoration_type {
1818
DECORATION_REF_TAG,
1919
DECORATION_REF_STASH,
2020
DECORATION_REF_HEAD,
21+
DECORATION_GRAFTED,
2122
};
2223

2324
static char decoration_colors[][COLOR_MAXLEN] = {
@@ -27,6 +28,7 @@ static char decoration_colors[][COLOR_MAXLEN] = {
2728
GIT_COLOR_BOLD_YELLOW, /* REF_TAG */
2829
GIT_COLOR_BOLD_MAGENTA, /* REF_STASH */
2930
GIT_COLOR_BOLD_CYAN, /* REF_HEAD */
31+
GIT_COLOR_BOLD_BLUE, /* GRAFTED */
3032
};
3133

3234
static const char *decorate_get_color(int decorate_use_color, enum decoration_type ix)
@@ -118,13 +120,23 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
118120
return 0;
119121
}
120122

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+
121132
void load_ref_decorations(int flags)
122133
{
123134
static int loaded;
124135
if (!loaded) {
125136
loaded = 1;
126137
for_each_ref(add_ref_decoration, &flags);
127138
head_ref(add_ref_decoration, &flags);
139+
for_each_commit_graft(add_graft_decoration, NULL);
128140
}
129141
}
130142

0 commit comments

Comments
 (0)