Skip to content

Commit 1ec5bfd

Browse files
stefanbellergitster
authored andcommitted
object: add repository argument to parse_object_buffer
Add a repository argument to allow the callers of parse_object_buffer to be more specific about which repository to act on. 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>
1 parent 5abddd1 commit 1ec5bfd

File tree

7 files changed

+18
-9
lines changed

7 files changed

+18
-9
lines changed

builtin/fast-export.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ static void export_blob(const struct object_id *oid)
244244
die ("Could not read blob %s", oid_to_hex(oid));
245245
if (check_object_signature(oid, buf, size, type_name(type)) < 0)
246246
die("sha1 mismatch in blob %s", oid_to_hex(oid));
247-
object = parse_object_buffer(oid, type, size, buf, &eaten);
247+
object = parse_object_buffer(the_repository, oid, type,
248+
size, buf, &eaten);
248249
}
249250

250251
if (!object)

builtin/fsck.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
392392
* verify_packfile(), data_valid variable for details.
393393
*/
394394
struct object *obj;
395-
obj = parse_object_buffer(oid, type, size, buffer, eaten);
395+
obj = parse_object_buffer(the_repository, oid, type, size, buffer,
396+
eaten);
396397
if (!obj) {
397398
errors_found |= ERROR_OBJECT;
398399
return error("%s: object corrupt or missing", oid_to_hex(oid));
@@ -525,7 +526,9 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
525526
if (!contents && type != OBJ_BLOB)
526527
BUG("read_loose_object streamed a non-blob");
527528

528-
obj = parse_object_buffer(oid, type, size, contents, &eaten);
529+
obj = parse_object_buffer(the_repository, oid, type, size,
530+
contents, &eaten);
531+
529532
if (!obj) {
530533
errors_found |= ERROR_OBJECT;
531534
error("%s: object could not be parsed: %s",

builtin/index-pack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
851851
* we do not need to free the memory here, as the
852852
* buf is deleted by the caller.
853853
*/
854-
obj = parse_object_buffer(oid, type, size, buf,
854+
obj = parse_object_buffer(the_repository, oid, type,
855+
size, buf,
855856
&eaten);
856857
if (!obj)
857858
die(_("invalid %s"), type_name(type));

builtin/unpack-objects.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ static void write_object(unsigned nr, enum object_type type,
265265
int eaten;
266266
hash_object_file(buf, size, type_name(type), &obj_list[nr].oid);
267267
added_object(nr, type, buf, size);
268-
obj = parse_object_buffer(&obj_list[nr].oid, type, size, buf,
268+
obj = parse_object_buffer(the_repository, &obj_list[nr].oid,
269+
type, size, buf,
269270
&eaten);
270271
if (!obj)
271272
die("invalid %s", type_name(type));

object.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct object *lookup_unknown_object(const unsigned char *sha1)
186186
return obj;
187187
}
188188

189-
struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
189+
struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
190190
{
191191
struct object *obj;
192192
*eaten_p = 0;
@@ -278,7 +278,8 @@ struct object *parse_object_the_repository(const struct object_id *oid)
278278
return NULL;
279279
}
280280

281-
obj = parse_object_buffer(oid, type, size, buffer, &eaten);
281+
obj = parse_object_buffer(the_repository, oid, type, size,
282+
buffer, &eaten);
282283
if (!eaten)
283284
free(buffer);
284285
return obj;

object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
135135
* parsing it. eaten_p indicates if the object has a borrowed copy
136136
* of buffer and the caller should not free() it.
137137
*/
138-
struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
138+
#define parse_object_buffer(r, o, t, s, b, e) parse_object_buffer_##r(o, t, s, b, e)
139+
struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
139140

140141
/** Returns the object, with potentially excess memory allocated. **/
141142
struct object *lookup_unknown_object(const unsigned char *sha1);

ref-filter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,8 @@ static void *get_obj(const struct object_id *oid, struct object **obj, unsigned
807807
void *buf = read_object_file(oid, &type, sz);
808808

809809
if (buf)
810-
*obj = parse_object_buffer(oid, type, *sz, buf, eaten);
810+
*obj = parse_object_buffer(the_repository, oid, type, *sz,
811+
buf, eaten);
811812
else
812813
*obj = NULL;
813814
return buf;

0 commit comments

Comments
 (0)