diff options
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c index e13bd2c3ee..6bca45c9f6 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -60,6 +60,7 @@ static struct cached_object empty_tree = { 0 }; +static struct packed_git *packed_git; static struct packed_git *last_found_pack; static struct cached_object *find_cached_object(const unsigned char *sha1) @@ -455,7 +456,6 @@ static unsigned int pack_open_fds; static unsigned int pack_max_fds; static size_t peak_pack_mapped; static size_t pack_mapped; -struct packed_git *packed_git; void pack_report(void) { @@ -1078,6 +1078,37 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local) return p; } +void foreach_packed_git(packed_git_foreach_fn fn, struct packed_git *hint, void *data) +{ + struct packed_git *p; + if (hint && ((*fn)(hint, data))) + return; + for (p = packed_git; p; p = p->next) + if (p != hint && (*fn)(p, data)) + return; +} + +size_t packed_git_count(void) +{ + size_t res = 0; + struct packed_git *p; + + for (p = packed_git; p; p = p->next) + ++res; + return res; +} + +size_t packed_git_local_count(void) +{ + size_t res = 0; + struct packed_git *p; + + for (p = packed_git; p; p = p->next) + if (p->pack_local) + ++res; + return res; +} + struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path) { const char *path = sha1_pack_name(sha1); @@ -2461,6 +2492,8 @@ struct packed_git *find_sha1_pack(const unsigned char *sha1, { struct packed_git *p; + if (!packs) + packs = packed_git; for (p = packs; p; p = p->next) { if (find_pack_entry_one(sha1, p)) return p; |