Skip to content

Commit afd69dc

Browse files
stefanbellergitster
authored andcommitted
object-store: prepare read_object_file to deal with any repo
As read_object_file is a widely used function (which is also regularly used in new code in flight between master..pu), changing its signature is painful is hard, as other series in flight rely on the original signature. It would burden the maintainer if we'd just change the signature. Introduce repo_read_object_file which takes the repository argument, and hide the original read_object_file as a macro behind NO_THE_REPOSITORY_COMPATIBILITY_MACROS, similar to e675765 (diff.c: remove implicit dependency on the_index, 2018-09-21) Add a coccinelle patch to convert existing callers, but do not apply the resulting patch to keep the diff of this patch small. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a3b72c8 commit afd69dc

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This file is used for the ongoing refactoring of
2+
// bringing the index or repository struct in all of
3+
// our code base.
4+
5+
@@
6+
expression E;
7+
expression F;
8+
expression G;
9+
@@
10+
- read_object_file(
11+
+ repo_read_object_file(the_repository,
12+
E, F, G)

object-store.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,16 @@ extern void *read_object_file_extended(struct repository *r,
165165
const struct object_id *oid,
166166
enum object_type *type,
167167
unsigned long *size, int lookup_replace);
168-
static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)
168+
static inline void *repo_read_object_file(struct repository *r,
169+
const struct object_id *oid,
170+
enum object_type *type,
171+
unsigned long *size)
169172
{
170-
return read_object_file_extended(the_repository, oid, type, size, 1);
173+
return read_object_file_extended(r, oid, type, size, 1);
171174
}
175+
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
176+
#define read_object_file(oid, type, size) repo_read_object_file(the_repository, oid, type, size)
177+
#endif
172178

173179
/* Read and unpack an object file into memory, write memory to an object file */
174180
int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);

0 commit comments

Comments
 (0)