Skip to content

Commit 5267d29

Browse files
pcloudsgitster
authored andcommitted
log: decorate "replaced" on to replaced commits
Old code also decorates "new" commits with "refs/replace/SHA1". This is now gone, but I guess no one will miss it. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 76f5df3 commit 5267d29

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

log-tree.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,22 @@ static void add_name_decoration(enum decoration_type type, const char *name, str
9292

9393
static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
9494
{
95-
struct object *obj = parse_object(sha1);
95+
struct object *obj;
9696
enum decoration_type type = DECORATION_NONE;
97+
98+
if (!prefixcmp(refname, "refs/replace/")) {
99+
unsigned char original_sha1[20];
100+
if (get_sha1_hex(refname + 13, original_sha1)) {
101+
warning("invalid replace ref %s", refname);
102+
return 0;
103+
}
104+
obj = parse_object(original_sha1);
105+
if (obj)
106+
add_name_decoration(DECORATION_GRAFTED, "replaced", obj);
107+
return 0;
108+
}
109+
110+
obj = parse_object(sha1);
97111
if (!obj)
98112
return 0;
99113

0 commit comments

Comments
 (0)