Skip to content

Commit 1f2e7ce

Browse files
stefanbellergitster
authored andcommitted
replace-object: add repository argument to lookup_replace_object
Add a repository argument to allow callers of lookup_replace_object 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. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9dfe98a commit 1f2e7ce

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

builtin/mktag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)
2525
enum object_type type;
2626
unsigned long size;
2727
void *buffer = read_object_file(oid, &type, &size);
28-
const struct object_id *repl = lookup_replace_object(oid);
28+
const struct object_id *repl = lookup_replace_object(the_repository, oid);
2929

3030
if (buffer) {
3131
if (type == type_from_string(expected_type))

object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ struct object *parse_object(const struct object_id *oid)
247247
unsigned long size;
248248
enum object_type type;
249249
int eaten;
250-
const struct object_id *repl = lookup_replace_object(oid);
250+
const struct object_id *repl = lookup_replace_object(the_repository, oid);
251251
void *buffer;
252252
struct object *obj;
253253

replace-object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ extern const struct object_id *do_lookup_replace_object_the_repository(const str
2323
* either sha1 or a pointer to a permanently-allocated value. When
2424
* object replacement is suppressed, always return sha1.
2525
*/
26-
static inline const struct object_id *lookup_replace_object(const struct object_id *oid)
26+
#define lookup_replace_object(r, s) lookup_replace_object_##r(s)
27+
static inline const struct object_id *lookup_replace_object_the_repository(const struct object_id *oid)
2728
{
2829
if (!check_replace_refs ||
2930
(the_repository->objects->replace_map &&

sha1_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
12401240
int already_retried = 0;
12411241

12421242
if (flags & OBJECT_INFO_LOOKUP_REPLACE)
1243-
real = lookup_replace_object(oid);
1243+
real = lookup_replace_object(the_repository, oid);
12441244

12451245
if (is_null_oid(real))
12461246
return -1;
@@ -1384,8 +1384,8 @@ void *read_object_file_extended(const struct object_id *oid,
13841384
const struct packed_git *p;
13851385
const char *path;
13861386
struct stat st;
1387-
const struct object_id *repl = lookup_replace ? lookup_replace_object(oid)
1388-
: oid;
1387+
const struct object_id *repl = lookup_replace ?
1388+
lookup_replace_object(the_repository, oid) : oid;
13891389

13901390
errno = 0;
13911391
data = read_object(repl->hash, type, size);

streaming.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct git_istream *open_istream(const struct object_id *oid,
140140
{
141141
struct git_istream *st;
142142
struct object_info oi = OBJECT_INFO_INIT;
143-
const struct object_id *real = lookup_replace_object(oid);
143+
const struct object_id *real = lookup_replace_object(the_repository, oid);
144144
enum input_source src = istream_source(real, type, &oi);
145145

146146
if (src < 0)

0 commit comments

Comments
 (0)