@@ -1033,7 +1033,8 @@ static void write_reused_pack_one(struct packed_git *reuse_packfile,
offset - (hashfile_total(out) - pack_start));
cur = offset;
- type = unpack_object_header(reuse_packfile, w_curs, &cur, &size);
+ type = unpack_object_header(the_repository, reuse_packfile, w_curs,
+ &cur, &size);
assert(type >= 0);
if (type == OBJ_OFS_DELTA) {
@@ -2067,7 +2067,8 @@ static int try_partial_reuse(struct bitmap_index *bitmap_git,
return -1; /* not actually in the pack */
delta_obj_offset = offset;
- type = unpack_object_header(pack->p, w_curs, &offset, &size);
+ type = unpack_object_header(the_repository, pack->p, w_curs, &offset,
+ &size);
if (type < 0)
return -1; /* broken packfile, punt */
@@ -127,7 +127,8 @@ static int verify_packfile(struct repository *r,
}
curpos = entries[i].offset;
- type = unpack_object_header(p, w_curs, &curpos, &size);
+ type = unpack_object_header(the_repository, p, w_curs, &curpos,
+ &size);
unuse_pack(w_curs);
if (type == OBJ_BLOB && big_file_threshold <= size) {
@@ -1169,9 +1169,8 @@ unsigned long get_size_from_delta(struct repository *repo, struct packed_git *p,
return get_delta_hdr_size(&data, delta_head+sizeof(delta_head));
}
-int unpack_object_header(struct packed_git *p,
- struct pack_window **w_curs,
- off_t *curpos,
+int unpack_object_header(struct repository *r, struct packed_git *p,
+ struct pack_window **w_curs, off_t *curpos,
unsigned long *sizep)
{
unsigned char *base;
@@ -1185,7 +1184,7 @@ int unpack_object_header(struct packed_git *p,
* the maximum deflated object size is 2^137, which is just
* insane, so we know won't exceed what we have been given.
*/
- base = use_pack(the_repository, p, w_curs, *curpos, &left);
+ base = use_pack(r, p, w_curs, *curpos, &left);
used = unpack_object_header_buffer(base, left, &type, sizep);
if (!used) {
type = OBJ_BAD;
@@ -1332,7 +1331,7 @@ static enum object_type packed_to_object_type(struct repository *r,
if (!base_offset)
goto unwind;
curpos = obj_offset = base_offset;
- type = unpack_object_header(p, w_curs, &curpos, &size);
+ type = unpack_object_header(r, p, w_curs, &curpos, &size);
if (type <= OBJ_NONE) {
/* If getting the base itself fails, we first
* retry the base, otherwise unwind */
@@ -1548,7 +1547,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,
if (!*oi->contentp)
type = OBJ_BAD;
} else {
- type = unpack_object_header(p, &w_curs, &curpos, &size);
+ type = unpack_object_header(r, p, &w_curs, &curpos, &size);
}
if (!oi->contentp && oi->sizep) {
@@ -1736,7 +1735,7 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
}
}
- type = unpack_object_header(p, &w_curs, &curpos, &size);
+ type = unpack_object_header(r, p, &w_curs, &curpos, &size);
if (type != OBJ_OFS_DELTA && type != OBJ_REF_DELTA)
break;
@@ -169,7 +169,8 @@ void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object
unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
unsigned long get_size_from_delta(struct repository *repo, struct packed_git *,
struct pack_window **, off_t);
-int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);
+int unpack_object_header(struct repository *repo, struct packed_git *,
+ struct pack_window **, off_t *, unsigned long *);
off_t get_delta_base(struct packed_git *p, struct pack_window **w_curs,
off_t *curpos, enum object_type type,
off_t delta_obj_offset);
@@ -334,7 +334,7 @@ static int close_istream_pack_non_delta(struct git_istream *st)
}
static int open_istream_pack_non_delta(struct git_istream *st,
- struct repository *r UNUSED,
+ struct repository *r,
const struct object_id *oid UNUSED,
enum object_type *type UNUSED)
{
@@ -343,7 +343,7 @@ static int open_istream_pack_non_delta(struct git_istream *st,
window = NULL;
- in_pack_type = unpack_object_header(st->u.in_pack.pack,
+ in_pack_type = unpack_object_header(r, st->u.in_pack.pack,
&window,
&st->u.in_pack.pos,
&st->size);
The function `unpack_object_header` currently relies on the global variable `the_repository`. To eliminate global variable usage in `packfile.c`, we should progressively shift the dependency on the_repository to higher layers. Let's remove its usage from this function and any related ones. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> --- builtin/pack-objects.c | 3 ++- pack-bitmap.c | 3 ++- pack-check.c | 3 ++- packfile.c | 13 ++++++------- packfile.h | 3 ++- streaming.c | 4 ++-- 6 files changed, 16 insertions(+), 13 deletions(-)