cat-file: use a single strbuf for all output
[gitweb.git] / blame.c
diff --git a/blame.c b/blame.c
index a5c9bd78ab09ce1d1ce40f82ccf13fcc8d973eec..58a7036847d9be574bbc3863d7ba4deb548628b7 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "refs.h"
+#include "object-store.h"
 #include "cache-tree.h"
 #include "mergesort.h"
 #include "diff.h"
@@ -118,7 +119,7 @@ static struct commit_list **append_parent(struct commit_list **tail, const struc
 {
        struct commit *parent;
 
-       parent = lookup_commit_reference(oid);
+       parent = lookup_commit_reference(the_repository, oid);
        if (!parent)
                die("no such commit %s", oid_to_hex(oid));
        return &commit_list_insert(parent, tail)->next;
@@ -129,17 +130,19 @@ static void append_merge_parents(struct commit_list **tail)
        int merge_head;
        struct strbuf line = STRBUF_INIT;
 
-       merge_head = open(git_path_merge_head(), O_RDONLY);
+       merge_head = open(git_path_merge_head(the_repository), O_RDONLY);
        if (merge_head < 0) {
                if (errno == ENOENT)
                        return;
-               die("cannot open '%s' for reading", git_path_merge_head());
+               die("cannot open '%s' for reading",
+                   git_path_merge_head(the_repository));
        }
 
        while (!strbuf_getwholeline_fd(&line, merge_head, '\n')) {
                struct object_id oid;
                if (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid))
-                       die("unknown line in '%s': %s", git_path_merge_head(), line.buf);
+                       die("unknown line in '%s': %s",
+                           git_path_merge_head(the_repository), line.buf);
                tail = append_parent(tail, &oid);
        }
        close(merge_head);
@@ -155,7 +158,7 @@ static void set_commit_buffer_from_strbuf(struct commit *c, struct strbuf *sb)
 {
        size_t len;
        void *buf = strbuf_detach(sb, &len);
-       set_commit_buffer(c, buf, len);
+       set_commit_buffer(the_repository, c, buf, len);
 }
 
 /*
@@ -173,7 +176,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
        struct strbuf buf = STRBUF_INIT;
        const char *ident;
        time_t now;
-       int size, len;
+       int len;
        struct cache_entry *ce;
        unsigned mode;
        struct strbuf msg = STRBUF_INIT;
@@ -271,8 +274,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
                        /* Let's not bother reading from HEAD tree */
                        mode = S_IFREG | 0644;
        }
-       size = cache_entry_size(len);
-       ce = xcalloc(1, size);
+       ce = make_empty_cache_entry(&the_index, len);
        oidcpy(&ce->oid, &origin->blob_oid);
        memcpy(ce->name, path, len);
        ce->ce_flags = create_ce_flags(0);
@@ -1671,7 +1673,7 @@ static struct commit *find_single_final(struct rev_info *revs,
                struct object *obj = revs->pending.objects[i].item;
                if (obj->flags & UNINTERESTING)
                        continue;
-               obj = deref_tag(obj, NULL, 0);
+               obj = deref_tag(the_repository, obj, NULL, 0);
                if (obj->type != OBJ_COMMIT)
                        die("Non commit %s?", revs->pending.objects[i].name);
                if (found)
@@ -1702,14 +1704,15 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
 
        /* Is that sole rev a committish? */
        obj = revs->pending.objects[0].item;
-       obj = deref_tag(obj, NULL, 0);
+       obj = deref_tag(the_repository, obj, NULL, 0);
        if (obj->type != OBJ_COMMIT)
                return NULL;
 
        /* Do we have HEAD? */
        if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
                return NULL;
-       head_commit = lookup_commit_reference_gently(&head_oid, 1);
+       head_commit = lookup_commit_reference_gently(the_repository,
+                                                    &head_oid, 1);
        if (!head_commit)
                return NULL;
 
@@ -1737,7 +1740,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
                struct object *obj = revs->pending.objects[i].item;
                if (!(obj->flags & UNINTERESTING))
                        continue;
-               obj = deref_tag(obj, NULL, 0);
+               obj = deref_tag(the_repository, obj, NULL, 0);
                if (obj->type != OBJ_COMMIT)
                        die("Non commit %s?", revs->pending.objects[i].name);
                if (found)