X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=log-tree.c;h=2c1f3e673ae7c9441cb171244d3fb91a8dd9fb1b;hb=2beec8973394e29353a9dccee45657870852ba33;hp=30cd5bb22800f5e897c1170e97721a4dcdb9c9d2;hpb=97d7fee2cb068f215a593c6e5623b265db45d3bc;p=git.git diff --git a/log-tree.c b/log-tree.c index 30cd5bb22..2c1f3e673 100644 --- a/log-tree.c +++ b/log-tree.c @@ -1,12 +1,48 @@ #include "cache.h" #include "diff.h" #include "commit.h" +#include "tag.h" #include "graph.h" #include "log-tree.h" #include "reflog-walk.h" +#include "refs.h" struct decoration name_decoration = { "object names" }; +static void add_name_decoration(const char *prefix, const char *name, struct object *obj) +{ + int plen = strlen(prefix); + int nlen = strlen(name); + struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + plen + nlen); + memcpy(res->name, prefix, plen); + memcpy(res->name + plen, name, nlen + 1); + res->next = add_decoration(&name_decoration, obj, res); +} + +static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data) +{ + struct object *obj = parse_object(sha1); + if (!obj) + return 0; + add_name_decoration("", refname, obj); + while (obj->type == OBJ_TAG) { + obj = ((struct tag *)obj)->tagged; + if (!obj) + break; + add_name_decoration("tag: ", refname, obj); + } + return 0; +} + +void load_ref_decorations(void) +{ + static int loaded; + if (!loaded) { + loaded = 1; + for_each_ref(add_ref_decoration, NULL); + } +} + static void show_parents(struct commit *commit, int abbrev) { struct commit_list *p;