blob: allow lookup_blob to handle arbitrary repositories
[gitweb.git] / commit.c
index b4dbfd889a337090bc5d4d2a5401a9bc3784f9ee..aa5557dee847a1c1d1de0c7827c80794c74b6652 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -24,25 +24,26 @@ int save_commit_buffer = 1;
 
 const char *commit_type = "commit";
 
-struct commit *lookup_commit_reference_gently(const struct object_id *oid,
-                                             int quiet)
+struct commit *lookup_commit_reference_gently_the_repository(
+               const struct object_id *oid, int quiet)
 {
-       struct object *obj = deref_tag(parse_object(the_repository, oid),
+       struct object *obj = deref_tag(the_repository,
+                                      parse_object(the_repository, oid),
                                       NULL, 0);
 
        if (!obj)
                return NULL;
-       return object_as_type(obj, OBJ_COMMIT, quiet);
+       return object_as_type(the_repository, obj, OBJ_COMMIT, quiet);
 }
 
-struct commit *lookup_commit_reference(const struct object_id *oid)
+struct commit *lookup_commit_reference_the_repository(const struct object_id *oid)
 {
-       return lookup_commit_reference_gently(oid, 0);
+       return lookup_commit_reference_gently(the_repository, oid, 0);
 }
 
 struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name)
 {
-       struct commit *c = lookup_commit_reference(oid);
+       struct commit *c = lookup_commit_reference(the_repository, oid);
        if (!c)
                die(_("could not parse %s"), ref_name);
        if (oidcmp(oid, &c->object.oid)) {
@@ -52,13 +53,13 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref
        return c;
 }
 
-struct commit *lookup_commit(const struct object_id *oid)
+struct commit *lookup_commit_the_repository(const struct object_id *oid)
 {
        struct object *obj = lookup_object(the_repository, oid->hash);
        if (!obj)
                return create_object(the_repository, oid->hash,
                                     alloc_commit_node(the_repository));
-       return object_as_type(obj, OBJ_COMMIT, 0);
+       return object_as_type(the_repository, obj, OBJ_COMMIT, 0);
 }
 
 struct commit *lookup_commit_reference_by_name(const char *name)
@@ -68,7 +69,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
 
        if (get_oid_committish(name, &oid))
                return NULL;
-       commit = lookup_commit_reference(&oid);
+       commit = lookup_commit_reference(the_repository, &oid);
        if (parse_commit(commit))
                return NULL;
        return commit;
@@ -262,14 +263,14 @@ struct commit_buffer {
 define_commit_slab(buffer_slab, struct commit_buffer);
 static struct buffer_slab buffer_slab = COMMIT_SLAB_INIT(1, buffer_slab);
 
-void set_commit_buffer(struct commit *commit, void *buffer, unsigned long size)
+void set_commit_buffer_the_repository(struct commit *commit, void *buffer, unsigned long size)
 {
        struct commit_buffer *v = buffer_slab_at(&buffer_slab, commit);
        v->buffer = buffer;
        v->size = size;
 }
 
-const void *get_cached_commit_buffer(const struct commit *commit, unsigned long *sizep)
+const void *get_cached_commit_buffer_the_repository(const struct commit *commit, unsigned long *sizep)
 {
        struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);
        if (!v) {
@@ -284,7 +285,7 @@ const void *get_cached_commit_buffer(const struct commit *commit, unsigned long
 
 const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)
 {
-       const void *ret = get_cached_commit_buffer(commit, sizep);
+       const void *ret = get_cached_commit_buffer(the_repository, commit, sizep);
        if (!ret) {
                enum object_type type;
                unsigned long size;
@@ -363,7 +364,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)
        return ret;
 }
 
-int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size, int check_graph)
+int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size, int check_graph)
 {
        const char *tail = buffer;
        const char *bufptr = buffer;
@@ -383,7 +384,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
        if (get_oid_hex(bufptr + 5, &parent) < 0)
                return error("bad tree pointer in commit %s",
                             oid_to_hex(&item->object.oid));
-       item->maybe_tree = lookup_tree(&parent);
+       item->maybe_tree = lookup_tree(the_repository, &parent);
        bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
        pptr = &item->parents;
 
@@ -402,7 +403,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
                 */
                if (graft && (graft->nr_parent < 0 || grafts_replace_parents))
                        continue;
-               new_parent = lookup_commit(&parent);
+               new_parent = lookup_commit(the_repository, &parent);
                if (new_parent)
                        pptr = &commit_list_insert(new_parent, pptr)->next;
        }
@@ -410,7 +411,8 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
                int i;
                struct commit *new_parent;
                for (i = 0; i < graft->nr_parent; i++) {
-                       new_parent = lookup_commit(&graft->parent[i]);
+                       new_parent = lookup_commit(the_repository,
+                                                  &graft->parent[i]);
                        if (!new_parent)
                                continue;
                        pptr = &commit_list_insert(new_parent, pptr)->next;
@@ -447,9 +449,9 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)
                return error("Object %s not a commit",
                             oid_to_hex(&item->object.oid));
        }
-       ret = parse_commit_buffer(item, buffer, size, 0);
+       ret = parse_commit_buffer(the_repository, item, buffer, size, 0);
        if (save_commit_buffer && !ret) {
-               set_commit_buffer(item, buffer, size);
+               set_commit_buffer(the_repository, item, buffer, size);
                return 0;
        }
        free(buffer);