Skip to content

Commit 8e4b0b6

Browse files
stefanbellergitster
authored andcommitted
object.c: allow parse_object to handle arbitrary repositories
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 108ed1a commit 8e4b0b6

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

object.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,28 +245,28 @@ struct object *parse_object_or_die(const struct object_id *oid,
245245
die(_("unable to parse object: %s"), name ? name : oid_to_hex(oid));
246246
}
247247

248-
struct object *parse_object_the_repository(const struct object_id *oid)
248+
struct object *parse_object(struct repository *r, const struct object_id *oid)
249249
{
250250
unsigned long size;
251251
enum object_type type;
252252
int eaten;
253-
const struct object_id *repl = lookup_replace_object(the_repository, oid);
253+
const struct object_id *repl = lookup_replace_object(r, oid);
254254
void *buffer;
255255
struct object *obj;
256256

257-
obj = lookup_object(the_repository, oid->hash);
257+
obj = lookup_object(r, oid->hash);
258258
if (obj && obj->parsed)
259259
return obj;
260260

261261
if ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||
262262
(!obj && has_object_file(oid) &&
263-
oid_object_info(the_repository, oid, NULL) == OBJ_BLOB)) {
263+
oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
264264
if (check_object_signature(repl, NULL, 0, NULL) < 0) {
265265
error("sha1 mismatch %s", oid_to_hex(oid));
266266
return NULL;
267267
}
268-
parse_blob_buffer(lookup_blob(the_repository, oid), NULL, 0);
269-
return lookup_object(the_repository, oid->hash);
268+
parse_blob_buffer(lookup_blob(r, oid), NULL, 0);
269+
return lookup_object(r, oid->hash);
270270
}
271271

272272
buffer = read_object_file(oid, &type, &size);
@@ -277,7 +277,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)
277277
return NULL;
278278
}
279279

280-
obj = parse_object_buffer(the_repository, oid, type, size,
280+
obj = parse_object_buffer(r, oid, type, size,
281281
buffer, &eaten);
282282
if (!eaten)
283283
free(buffer);

object.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ void *object_as_type(struct repository *r, struct object *obj, enum object_type
124124
*
125125
* Returns NULL if the object is missing or corrupt.
126126
*/
127-
#define parse_object(r, oid) parse_object_##r(oid)
128-
struct object *parse_object_the_repository(const struct object_id *oid);
127+
struct object *parse_object(struct repository *r, const struct object_id *oid);
129128

130129
/*
131130
* Like parse_object, but will die() instead of returning NULL. If the

0 commit comments

Comments
 (0)