From 720aaa1a74a8cf5fcc35bb294013d30d218bec01 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 25 Apr 2018 11:21:02 -0700 Subject: packfile: add repository argument to packed_object_info Add a repository argument to allow callers of packed_object_info 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 Signed-off-by: Stefan Beller Reviewed-by: Jonathan Tan Signed-off-by: Junio C Hamano --- packfile.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packfile.h') diff --git a/packfile.h b/packfile.h index a92c0b241c..bc8d840b1b 100644 --- a/packfile.h +++ b/packfile.h @@ -125,7 +125,8 @@ extern void release_pack_memory(size_t); /* global flag to enable extra checks when accessing packed objects */ extern int do_check_packed_object_crc; -extern int packed_object_info(struct packed_git *pack, off_t offset, struct object_info *); +#define packed_object_info(r, p, o, oi) packed_object_info_##r(p, o, oi) +extern int packed_object_info_the_repository(struct packed_git *pack, off_t offset, struct object_info *); extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1); extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1); -- cgit v1.2.3 From 57a6a500be8d8ee903a1dc9ea607063a1bc88a0b Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 25 Apr 2018 11:21:04 -0700 Subject: packfile: add repository argument to unpack_entry Add a repository argument to allow the callers of unpack_entry 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 Signed-off-by: Stefan Beller Reviewed-by: Jonathan Tan Signed-off-by: Junio C Hamano --- packfile.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packfile.h') diff --git a/packfile.h b/packfile.h index bc8d840b1b..1efa57a90e 100644 --- a/packfile.h +++ b/packfile.h @@ -115,7 +115,8 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n); extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *); extern int is_pack_valid(struct packed_git *); -extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *); +#define unpack_entry(r, p, of, ot, s) unpack_entry_##r(p, of, ot, s) +extern void *unpack_entry_the_repository(struct packed_git *, off_t, enum object_type *, unsigned long *); extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep); extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t); extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *); -- cgit v1.2.3 From 9d98354f48997faf8251c566d909957f6ae427d5 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 25 Apr 2018 11:21:06 -0700 Subject: cache.h: allow oid_object_info to handle arbitrary repositories This involves also adapting oid_object_info_extended and a some internal functions that are used to implement these. It all has to happen in one patch, because of a single recursive chain of calls visits all these functions. oid_object_info_extended is also used in partial clones, which allow fetching missing objects. As this series will not add the repository struct to the transport code and fetch_object(), add a TODO note and omit fetching if a user tries to use a partial clone in a repository other than the_repository. Among the functions modified to handle arbitrary repositories, unpack_entry() is one of them. Note that it still references the globals "delta_base_cache" and "delta_base_cached", but those are safe to be referenced (the former is indexed partly by "struct packed_git *", which is repo-specific, and the latter is only used to limit the size of the former as an optimization). Helped-by: Brandon Williams Helped-by: Jonathan Tan Signed-off-by: Jonathan Nieder Signed-off-by: Stefan Beller Reviewed-by: Jonathan Tan Signed-off-by: Junio C Hamano --- packfile.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packfile.h') diff --git a/packfile.h b/packfile.h index 1efa57a90e..fdfddb89b5 100644 --- a/packfile.h +++ b/packfile.h @@ -115,8 +115,7 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n); extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *); extern int is_pack_valid(struct packed_git *); -#define unpack_entry(r, p, of, ot, s) unpack_entry_##r(p, of, ot, s) -extern void *unpack_entry_the_repository(struct packed_git *, off_t, enum object_type *, unsigned long *); +extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, unsigned long *); extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep); extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t); extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *); @@ -126,8 +125,9 @@ extern void release_pack_memory(size_t); /* global flag to enable extra checks when accessing packed objects */ extern int do_check_packed_object_crc; -#define packed_object_info(r, p, o, oi) packed_object_info_##r(p, o, oi) -extern int packed_object_info_the_repository(struct packed_git *pack, off_t offset, struct object_info *); +extern int packed_object_info(struct repository *r, + struct packed_git *pack, + off_t offset, struct object_info *); extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1); extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1); -- cgit v1.2.3