From: Jonathan Nieder <jrnieder@xxxxxxxxx> Add a repository argument to allow callers of read_sha1_file_extended to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. The included coccinelle semantic patch will adapt any new callers in the diff produced by `make coccicheck`. Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> --- contrib/coccinelle/object_store.cocci | 10 ++++++++++ object-store.h | 5 +++-- sha1_file.c | 2 +- streaming.c | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/contrib/coccinelle/object_store.cocci b/contrib/coccinelle/object_store.cocci index 6e6e5454da..915dd176dd 100644 --- a/contrib/coccinelle/object_store.cocci +++ b/contrib/coccinelle/object_store.cocci @@ -15,3 +15,13 @@ expression H; check_sha1_signature( +the_repository, E, F, G, H) + +@@ +expression E; +expression F; +expression G; +expression H; +@@ + read_sha1_file_extended( ++the_repository, + E, F, G, H) diff --git a/object-store.h b/object-store.h index 178268a048..d6462cd9f1 100644 --- a/object-store.h +++ b/object-store.h @@ -82,12 +82,13 @@ struct packed_git { char pack_name[FLEX_ARRAY]; /* more */ }; -extern void *read_sha1_file_extended(const unsigned char *sha1, +#define read_sha1_file_extended(r, s, t, sz, l) read_sha1_file_extended_##r(s, t, sz, l) +extern void *read_sha1_file_extended_the_repository(const unsigned char *sha1, enum object_type *type, unsigned long *size, int lookup_replace); static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *type, unsigned long *size) { - return read_sha1_file_extended(sha1, type, size, 1); + return read_sha1_file_extended(the_repository, sha1, type, size, 1); } /* Read and unpack a sha1 file into memory, write memory to a sha1 file */ diff --git a/sha1_file.c b/sha1_file.c index e62595e3e2..2d9a794654 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1357,7 +1357,7 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type, * deal with them should arrange to call read_object() and give error * messages themselves. */ -void *read_sha1_file_extended(const unsigned char *sha1, +void *read_sha1_file_extended_the_repository(const unsigned char *sha1, enum object_type *type, unsigned long *size, int lookup_replace) diff --git a/streaming.c b/streaming.c index bc3c4811ca..f0ff5e7245 100644 --- a/streaming.c +++ b/streaming.c @@ -490,7 +490,8 @@ 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(the_repository, sha1, + type, &st->size, 0); st->u.incore.read_ptr = 0; st->vtbl = &incore_vtbl; -- 2.15.1.433.g936d1b9894.dirty