rebase -i: rewrite setup_reflog_action() in C
[gitweb.git] / streaming.c
index 3f4be1ea2c3e9ed68190b8e2bb54c9b3de6d853b..d1e6b2dce6877cb1407ac9d38e65d8b2bae25daa 100644 (file)
@@ -3,6 +3,9 @@
  */
 #include "cache.h"
 #include "streaming.h"
+#include "repository.h"
+#include "object-store.h"
+#include "replace-object.h"
 #include "packfile.h"
 
 enum input_source {
@@ -105,19 +108,16 @@ ssize_t read_istream(struct git_istream *st, void *buf, size_t sz)
        return st->vtbl->read(st, buf, sz);
 }
 
-static enum input_source istream_source(const unsigned char *sha1,
+static enum input_source istream_source(const struct object_id *oid,
                                        enum object_type *type,
                                        struct object_info *oi)
 {
        unsigned long size;
        int status;
-       struct object_id oid;
-
-       hashcpy(oid.hash, sha1);
 
        oi->typep = type;
        oi->sizep = &size;
-       status = oid_object_info_extended(&oid, oi, 0);
+       status = oid_object_info_extended(the_repository, oid, oi, 0);
        if (status < 0)
                return stream_error;
 
@@ -140,18 +140,15 @@ struct git_istream *open_istream(const struct object_id *oid,
 {
        struct git_istream *st;
        struct object_info oi = OBJECT_INFO_INIT;
-       const unsigned char *real = lookup_replace_object(oid->hash);
+       const struct object_id *real = lookup_replace_object(the_repository, oid);
        enum input_source src = istream_source(real, type, &oi);
-       struct object_id realoid;
-
-       hashcpy(realoid.hash, real);
 
        if (src < 0)
                return NULL;
 
        st = xmalloc(sizeof(*st));
-       if (open_istream_tbl[src](st, &oi, &realoid, type)) {
-               if (open_istream_incore(st, &oi, &realoid, type)) {
+       if (open_istream_tbl[src](st, &oi, real, type)) {
+               if (open_istream_incore(st, &oi, real, type)) {
                        free(st);
                        return NULL;
                }
@@ -341,7 +338,8 @@ static struct stream_vtbl loose_vtbl = {
 
 static open_method_decl(loose)
 {
-       st->u.loose.mapped = map_sha1_file(oid->hash, &st->u.loose.mapsize);
+       st->u.loose.mapped = map_sha1_file(the_repository,
+                                          oid->hash, &st->u.loose.mapsize);
        if (!st->u.loose.mapped)
                return -1;
        if ((unpack_sha1_header(&st->z,
@@ -492,7 +490,7 @@ static struct stream_vtbl incore_vtbl = {
 
 static open_method_decl(incore)
 {
-       st->u.incore.buf = read_sha1_file_extended(oid->hash, type, &st->size, 0);
+       st->u.incore.buf = read_object_file_extended(oid, type, &st->size, 0);
        st->u.incore.read_ptr = 0;
        st->vtbl = &incore_vtbl;