summaryrefslogtreecommitdiff
path: root/log-tree.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2008-09-04 21:39:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-09-05 00:01:41 (GMT)
commitcab4feb67db64d3d201145d9748b33d148f96185 (patch)
tree75f1cb9ff454e621d7b91ed139ce550ae0c007c0 /log-tree.c
parent5e9bf11c1a3052f01f86d7eb28ae4c5b8d9c7495 (diff)
downloadgit-cab4feb67db64d3d201145d9748b33d148f96185.zip
git-cab4feb67db64d3d201145d9748b33d148f96185.tar.gz
git-cab4feb67db64d3d201145d9748b33d148f96185.tar.bz2
move load_ref_decorations() to log-tree.c and export it
log-tree.c is the ideal place for load_ref_decorations() and its helper functions to live in, because the variable name_decoration they're operating on is already located there, so move them thither. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/log-tree.c b/log-tree.c
index 30cd5bb..2c1f3e6 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;