summaryrefslogtreecommitdiff
path: root/streaming.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2018-03-12 02:27:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-03-14 16:23:50 (GMT)
commit575042a04f671fa1a9cf9d5c21b30a2dadbe6c7e (patch)
tree5707e4cf9f88267995bd89da54b3bf72f3fe496e /streaming.c
parent0d4a8b5b6ce4db0846b3545a753f0e698db3eda9 (diff)
downloadgit-575042a04f671fa1a9cf9d5c21b30a2dadbe6c7e.zip
git-575042a04f671fa1a9cf9d5c21b30a2dadbe6c7e.tar.gz
git-575042a04f671fa1a9cf9d5c21b30a2dadbe6c7e.tar.bz2
streaming: convert istream internals to struct object_id
Convert the various open_istream variants to take a pointer to struct object_id. Introduce a temporary, which will be removed later, to work around the fact that lookup_replace_object still returns a pointer to unsigned char. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'streaming.c')
-rw-r--r--streaming.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/streaming.c b/streaming.c
index 344678e..3f4be1e 100644
--- a/streaming.c
+++ b/streaming.c
@@ -14,7 +14,7 @@ enum input_source {
typedef int (*open_istream_fn)(struct git_istream *,
struct object_info *,
- const unsigned char *,
+ const struct object_id *,
enum object_type *);
typedef int (*close_istream_fn)(struct git_istream *);
typedef ssize_t (*read_istream_fn)(struct git_istream *, char *, size_t);
@@ -27,7 +27,7 @@ struct stream_vtbl {
#define open_method_decl(name) \
int open_istream_ ##name \
(struct git_istream *st, struct object_info *oi, \
- const unsigned char *sha1, \
+ const struct object_id *oid, \
enum object_type *type)
#define close_method_decl(name) \
@@ -142,13 +142,16 @@ struct git_istream *open_istream(const struct object_id *oid,
struct object_info oi = OBJECT_INFO_INIT;
const unsigned char *real = lookup_replace_object(oid->hash);
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, real, type)) {
- if (open_istream_incore(st, &oi, real, type)) {
+ if (open_istream_tbl[src](st, &oi, &realoid, type)) {
+ if (open_istream_incore(st, &oi, &realoid, type)) {
free(st);
return NULL;
}
@@ -338,7 +341,7 @@ static struct stream_vtbl loose_vtbl = {
static open_method_decl(loose)
{
- st->u.loose.mapped = map_sha1_file(sha1, &st->u.loose.mapsize);
+ st->u.loose.mapped = map_sha1_file(oid->hash, &st->u.loose.mapsize);
if (!st->u.loose.mapped)
return -1;
if ((unpack_sha1_header(&st->z,
@@ -489,7 +492,7 @@ static struct stream_vtbl incore_vtbl = {
static open_method_decl(incore)
{
- st->u.incore.buf = read_sha1_file_extended(sha1, type, &st->size, 0);
+ st->u.incore.buf = read_sha1_file_extended(oid->hash, type, &st->size, 0);
st->u.incore.read_ptr = 0;
st->vtbl = &incore_vtbl;