A new helper function allows to efficiently query the size and real type
of an object in a packfile based on its position on the packfile index.
This is particularly useful when trying to parse all the information of
an index in memory.
---
cache.h | 1 +
sha1_file.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/cache.h b/cache.h
index bbe5e2a..26e4567 100644
--- a/cache.h
+++ b/cache.h
@@ -1104,6 +1104,7 @@ extern void clear_delta_base_cache(void);
extern struct packed_git *add_packed_git(const char *, int, int);
extern const unsigned char *nth_packed_object_sha1(struct packed_git *,
uint32_t);
extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t);
+extern int nth_packed_object_info(struct packed_git *p, uint32_t n, unsigned
long *sizep);
extern int find_pack_entry_pos(const unsigned char *sha1, struct packed_git
*p);
extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
extern int is_pack_valid(struct packed_git *);
diff --git a/sha1_file.c b/sha1_file.c
index 018a847..fd5bd01 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2223,6 +2223,12 @@ off_t nth_packed_object_offset(const struct packed_git
*p, uint32_t n)
}
}
+int nth_packed_object_info(struct packed_git *p, uint32_t n, unsigned long
*sizep)
+{
+ off_t offset = nth_packed_object_offset(p, n);
+ return packed_object_info(p, offset, sizep, NULL);
+}
+
int find_pack_entry_pos(const unsigned char *sha1, struct packed_git *p)
{
const uint32_t *level1_ofs = p->index_data;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html