diff options
Diffstat (limited to 'packfile.c')
-rw-r--r-- | packfile.c | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/packfile.c b/packfile.c index 8de87f904b..55d383ed0a 100644 --- a/packfile.c +++ b/packfile.c @@ -1104,9 +1104,9 @@ static const unsigned char *get_delta_base_sha1(struct packed_git *p, return NULL; } -#define retry_bad_packed_offset(r, p, o) \ - retry_bad_packed_offset_##r(p, o) -static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t obj_offset) +static int retry_bad_packed_offset(struct repository *r, + struct packed_git *p, + off_t obj_offset) { int type; struct revindex_entry *revidx; @@ -1116,7 +1116,7 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob return OBJ_BAD; nth_packed_object_oid(&oid, p, revidx->nr); mark_bad_packed_object(p, oid.hash); - type = oid_object_info(the_repository, &oid, NULL); + type = oid_object_info(r, &oid, NULL); if (type <= OBJ_NONE) return OBJ_BAD; return type; @@ -1124,13 +1124,12 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob #define POI_STACK_PREALLOC 64 -#define packed_to_object_type(r, p, o, t, w, c) \ - packed_to_object_type_##r(p, o, t, w, c) -static enum object_type packed_to_object_type_the_repository(struct packed_git *p, - off_t obj_offset, - enum object_type type, - struct pack_window **w_curs, - off_t curpos) +static enum object_type packed_to_object_type(struct repository *r, + struct packed_git *p, + off_t obj_offset, + enum object_type type, + struct pack_window **w_curs, + off_t curpos) { off_t small_poi_stack[POI_STACK_PREALLOC]; off_t *poi_stack = small_poi_stack; @@ -1157,7 +1156,7 @@ static enum object_type packed_to_object_type_the_repository(struct packed_git * if (type <= OBJ_NONE) { /* If getting the base itself fails, we first * retry the base, otherwise unwind */ - type = retry_bad_packed_offset(the_repository, p, base_offset); + type = retry_bad_packed_offset(r, p, base_offset); if (type > OBJ_NONE) goto out; goto unwind; @@ -1185,7 +1184,7 @@ out: unwind: while (poi_stack_nr) { obj_offset = poi_stack[--poi_stack_nr]; - type = retry_bad_packed_offset(the_repository, p, obj_offset); + type = retry_bad_packed_offset(r, p, obj_offset); if (type > OBJ_NONE) goto out; } @@ -1272,15 +1271,15 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent) free(ent); } -#define cache_or_unpack_entry(r, p, bo, bs, t) cache_or_unpack_entry_##r(p, bo, bs, t) -static void *cache_or_unpack_entry_the_repository(struct packed_git *p, off_t base_offset, - unsigned long *base_size, enum object_type *type) +static void *cache_or_unpack_entry(struct repository *r, struct packed_git *p, + off_t base_offset, unsigned long *base_size, + enum object_type *type) { struct delta_base_cache_entry *ent; ent = get_delta_base_cache_entry(p, base_offset); if (!ent) - return unpack_entry(the_repository, p, base_offset, type, base_size); + return unpack_entry(r, p, base_offset, type, base_size); if (type) *type = ent->type; @@ -1334,8 +1333,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset, hashmap_add(&delta_base_cache, ent); } -int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset, - struct object_info *oi) +int packed_object_info(struct repository *r, struct packed_git *p, + off_t obj_offset, struct object_info *oi) { struct pack_window *w_curs = NULL; unsigned long size; @@ -1347,7 +1346,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset, * a "real" type later if the caller is interested. */ if (oi->contentp) { - *oi->contentp = cache_or_unpack_entry(the_repository, p, obj_offset, oi->sizep, + *oi->contentp = cache_or_unpack_entry(r, p, obj_offset, oi->sizep, &type); if (!*oi->contentp) type = OBJ_BAD; @@ -1381,7 +1380,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset, if (oi->typep || oi->type_name) { enum object_type ptot; - ptot = packed_to_object_type(the_repository, p, obj_offset, + ptot = packed_to_object_type(r, p, obj_offset, type, &w_curs, curpos); if (oi->typep) *oi->typep = ptot; @@ -1470,10 +1469,10 @@ struct unpack_entry_stack_ent { unsigned long size; }; -#define read_object(r, o, t, s) read_object_##r(o, t, s) -static void *read_object_the_repository(const struct object_id *oid, - enum object_type *type, - unsigned long *size) +static void *read_object(struct repository *r, + const struct object_id *oid, + enum object_type *type, + unsigned long *size) { struct object_info oi = OBJECT_INFO_INIT; void *content; @@ -1481,14 +1480,13 @@ static void *read_object_the_repository(const struct object_id *oid, oi.sizep = size; oi.contentp = &content; - if (oid_object_info_extended(the_repository, oid, &oi, 0) < 0) + if (oid_object_info_extended(r, oid, &oi, 0) < 0) return NULL; return content; } -void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset, - enum object_type *final_type, - unsigned long *final_size) +void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset, + enum object_type *final_type, unsigned long *final_size) { struct pack_window *w_curs = NULL; off_t curpos = obj_offset; @@ -1618,7 +1616,7 @@ void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset, oid_to_hex(&base_oid), (uintmax_t)obj_offset, p->pack_name); mark_bad_packed_object(p, base_oid.hash); - base = read_object(the_repository, &base_oid, &type, &base_size); + base = read_object(r, &base_oid, &type, &base_size); external_base = base; } } |