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 <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Apr 11, 2018 at 17:21 UTC
1f2e7ceabcc1559e5b3e49df91036d3106f727f4
5 files changed
+8
-7
builtin/mktag.c
+1
-1
@@ -25,7 +25,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)
25
enum object_type type;
26
unsigned long size;
27
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);
29
30
if (buffer) {
31
if (type == type_from_string(expected_type))
object.c
+1
-1
@@ -247,7 +247,7 @@ struct object *parse_object(const struct object_id *oid)
247
unsigned long size;
248
enum object_type type;
249
int eaten;
250
- const struct object_id *repl = lookup_replace_object(oid);
250
+ const struct object_id *repl = lookup_replace_object(the_repository, oid);
251
void *buffer;
252
struct object *obj;
253
replace-object.h
+2
-1
@@ -23,7 +23,8 @@ extern const struct object_id *do_lookup_replace_object_the_repository(const str
23
* either sha1 or a pointer to a permanently-allocated value. When
24
* object replacement is suppressed, always return sha1.
25
*/
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)
28
{
29
if (!check_replace_refs ||
30
(the_repository->objects->replace_map &&
sha1_file.c
+3
-3
@@ -1240,7 +1240,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
1240
int already_retried = 0;
1241
1242
if (flags & OBJECT_INFO_LOOKUP_REPLACE)
1243
- real = lookup_replace_object(oid);
1243
+ real = lookup_replace_object(the_repository, oid);
1244
1245
if (is_null_oid(real))
1246
return -1;
@@ -1384,8 +1384,8 @@ void *read_object_file_extended(const struct object_id *oid,
1384
const struct packed_git *p;
1385
const char *path;
1386
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;
1389
1390
errno = 0;
1391
data = read_object(repl->hash, type, size);
streaming.c
+1
-1
@@ -140,7 +140,7 @@ struct git_istream *open_istream(const struct object_id *oid,
140
{
141
struct git_istream *st;
142
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);
144
enum input_source src = istream_source(real, type, &oi);
145
146
if (src < 0)