diff --git a/archive-tar.c b/archive-tar.c index b10c9b8911ff7d..01a1cbdb979b26 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -121,7 +121,7 @@ static int stream_blocked(const unsigned char *sha1) char buf[BLOCKSIZE]; ssize_t readlen; - st = open_istream(sha1, &type, &sz, NULL); + st = open_istream(the_repository, sha1, &type, &sz, NULL); if (!st) return error("cannot stream blob %s", sha1_to_hex(sha1)); for (;;) { diff --git a/archive-zip.c b/archive-zip.c index 03321b9777b02e..c199ec2d599a4e 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -340,7 +340,8 @@ static int write_zip_entry(struct archiver_args *args, if (S_ISREG(mode) && type == OBJ_BLOB && !args->convert && size > big_file_threshold) { - stream = open_istream(sha1, &type, &size, NULL); + stream = open_istream(the_repository, sha1, &type, + &size, NULL); if (!stream) return error("cannot stream blob %s", sha1_to_hex(sha1)); diff --git a/builtin/index-pack.c b/builtin/index-pack.c index b42bf12f65ad24..f78e9d2e65edb3 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -774,7 +774,8 @@ static int check_collison(struct object_entry *entry) memset(&data, 0, sizeof(data)); data.entry = entry; - data.st = open_istream(entry->idx.oid.hash, &type, &size, NULL); + data.st = open_istream(the_repository, entry->idx.oid.hash, &type, + &size, NULL); if (!data.st) return -1; if (size != entry->size || type != entry->type) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 128e5e36768e08..77275058e48603 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -270,7 +270,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent if (!usable_delta) { if (entry->type == OBJ_BLOB && entry->size > big_file_threshold && - (st = open_istream(entry->idx.oid.hash, &type, &size, NULL)) != NULL) + (st = open_istream(the_repository, entry->idx.oid.hash, &type, &size, NULL)) != NULL) buf = NULL; else { buf = read_sha1_file(the_repository, diff --git a/contrib/coccinelle/object_store.cocci b/contrib/coccinelle/object_store.cocci index 72066e37685e55..3d29868dbf6879 100644 --- a/contrib/coccinelle/object_store.cocci +++ b/contrib/coccinelle/object_store.cocci @@ -34,3 +34,13 @@ expression G; read_sha1_file( +the_repository, E, F, G) + +@@ +expression E; +expression F; +expression G; +expression H; +@@ +open_istream( ++ the_repository, + E, F, G, H) diff --git a/sha1_file.c b/sha1_file.c index e1427c0982e57d..a5ad67143da415 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -817,7 +817,7 @@ int check_sha1_signature_the_repository(const unsigned char *sha1, void *map, return hashcmp(sha1, real_sha1) ? -1 : 0; } - st = open_istream(sha1, &obj_type, &size, NULL); + st = open_istream(the_repository, sha1, &obj_type, &size, NULL); if (!st) return -1; diff --git a/streaming.c b/streaming.c index 8c1e1a16015302..90acf7448f5615 100644 --- a/streaming.c +++ b/streaming.c @@ -136,7 +136,7 @@ static enum input_source istream_source(const unsigned char *sha1, } } -struct git_istream *open_istream(const unsigned char *sha1, +struct git_istream *open_istream_the_repository(const unsigned char *sha1, enum object_type *type, unsigned long *size, struct stream_filter *filter) @@ -524,7 +524,7 @@ int stream_blob_to_fd(int fd, const struct object_id *oid, struct stream_filter ssize_t kept = 0; int result = -1; - st = open_istream(oid->hash, &type, &sz, filter); + st = open_istream(the_repository, oid->hash, &type, &sz, filter); if (!st) { if (filter) free_stream_filter(filter); diff --git a/streaming.h b/streaming.h index 73c1d156b35289..9f4d5aeee25473 100644 --- a/streaming.h +++ b/streaming.h @@ -8,7 +8,8 @@ /* opaque */ struct git_istream; -extern struct git_istream *open_istream(const unsigned char *, enum object_type *, unsigned long *, struct stream_filter *); +#define open_istream(r, s, t, sz, f) open_istream_##r(s, t, sz, f) +extern struct git_istream *open_istream_the_repository(const unsigned char *, enum object_type *, unsigned long *, struct stream_filter *); extern int close_istream(struct git_istream *); extern ssize_t read_istream(struct git_istream *, void *, size_t);