line-range.h: drop extern from function declaration
[gitweb.git] / tag.c
diff --git a/tag.c b/tag.c
index 46b5882ee12022a607bbdd4950853eacfea28291..1db663d71623a493286c90b13532c7d1cf73f517 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -6,6 +6,7 @@
 #include "blob.h"
 #include "alloc.h"
 #include "gpg-interface.h"
+#include "packfile.h"
 
 const char *tag_type = "tag";
 
@@ -64,15 +65,20 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
        return ret;
 }
 
-struct object *deref_tag_the_repository(struct object *o, const char *warn, int warnlen)
+struct object *deref_tag(struct repository *r, struct object *o, const char *warn, int warnlen)
 {
+       struct object_id *last_oid = NULL;
        while (o && o->type == OBJ_TAG)
-               if (((struct tag *)o)->tagged)
-                       o = parse_object(the_repository,
-                                        &((struct tag *)o)->tagged->oid);
-               else
+               if (((struct tag *)o)->tagged) {
+                       last_oid = &((struct tag *)o)->tagged->oid;
+                       o = parse_object(r, last_oid);
+               } else {
+                       last_oid = NULL;
                        o = NULL;
+               }
        if (!o && warn) {
+               if (last_oid && is_promisor_object(last_oid))
+                       return NULL;
                if (!warnlen)
                        warnlen = strlen(warn);
                error("missing object referenced by '%.*s'", warnlen, warn);
@@ -126,7 +132,7 @@ void release_tag_memory(struct tag *t)
        t->date = 0;
 }
 
-int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size)
+int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size)
 {
        struct object_id oid;
        char type[20];
@@ -154,13 +160,13 @@ int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned
        bufptr = nl + 1;
 
        if (!strcmp(type, blob_type)) {
-               item->tagged = (struct object *)lookup_blob(the_repository, &oid);
+               item->tagged = (struct object *)lookup_blob(r, &oid);
        } else if (!strcmp(type, tree_type)) {
-               item->tagged = (struct object *)lookup_tree(the_repository, &oid);
+               item->tagged = (struct object *)lookup_tree(r, &oid);
        } else if (!strcmp(type, commit_type)) {
-               item->tagged = (struct object *)lookup_commit(the_repository, &oid);
+               item->tagged = (struct object *)lookup_commit(r, &oid);
        } else if (!strcmp(type, tag_type)) {
-               item->tagged = (struct object *)lookup_tag(the_repository, &oid);
+               item->tagged = (struct object *)lookup_tag(r, &oid);
        } else {
                error("Unknown type %s", type);
                item->tagged = NULL;