commit: add repository argument to lookup_commit
[gitweb.git] / tag.c
diff --git a/tag.c b/tag.c
index 3d37c1bd251c5f8c5eb06ede72ab57b323888709..5dcdf7bf6f9b46ab33b515daa0995f3dca2599a3 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -1,8 +1,10 @@
 #include "cache.h"
 #include "tag.h"
+#include "object-store.h"
 #include "commit.h"
 #include "tree.h"
 #include "blob.h"
+#include "alloc.h"
 #include "gpg-interface.h"
 
 const char *tag_type = "tag";
@@ -66,7 +68,8 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)
 {
        while (o && o->type == OBJ_TAG)
                if (((struct tag *)o)->tagged)
-                       o = parse_object(&((struct tag *)o)->tagged->oid);
+                       o = parse_object(the_repository,
+                                        &((struct tag *)o)->tagged->oid);
                else
                        o = NULL;
        if (!o && warn) {
@@ -80,7 +83,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)
 struct object *deref_tag_noverify(struct object *o)
 {
        while (o && o->type == OBJ_TAG) {
-               o = parse_object(&o->oid);
+               o = parse_object(the_repository, &o->oid);
                if (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged)
                        o = ((struct tag *)o)->tagged;
                else
@@ -91,10 +94,11 @@ struct object *deref_tag_noverify(struct object *o)
 
 struct tag *lookup_tag(const struct object_id *oid)
 {
-       struct object *obj = lookup_object(oid->hash);
+       struct object *obj = lookup_object(the_repository, oid->hash);
        if (!obj)
-               return create_object(oid->hash, alloc_tag_node());
-       return object_as_type(obj, OBJ_TAG, 0);
+               return create_object(the_repository, oid->hash,
+                                    alloc_tag_node(the_repository));
+       return object_as_type(the_repository, obj, OBJ_TAG, 0);
 }
 
 static timestamp_t parse_tag_date(const char *buf, const char *tail)
@@ -114,6 +118,14 @@ static timestamp_t parse_tag_date(const char *buf, const char *tail)
        return parse_timestamp(dateptr, NULL, 10);
 }
 
+void release_tag_memory(struct tag *t)
+{
+       free(t->tag);
+       t->tagged = NULL;
+       t->object.parsed = 0;
+       t->date = 0;
+}
+
 int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
 {
        struct object_id oid;
@@ -142,11 +154,11 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
        bufptr = nl + 1;
 
        if (!strcmp(type, blob_type)) {
-               item->tagged = (struct object *)lookup_blob(&oid);
+               item->tagged = (struct object *)lookup_blob(the_repository, &oid);
        } else if (!strcmp(type, tree_type)) {
-               item->tagged = (struct object *)lookup_tree(&oid);
+               item->tagged = (struct object *)lookup_tree(the_repository, &oid);
        } else if (!strcmp(type, commit_type)) {
-               item->tagged = (struct object *)lookup_commit(&oid);
+               item->tagged = (struct object *)lookup_commit(the_repository, &oid);
        } else if (!strcmp(type, tag_type)) {
                item->tagged = (struct object *)lookup_tag(&oid);
        } else {