diff --git a/cache.h b/cache.h index 79066e57dc..5a9813b771 100644 --- a/cache.h +++ b/cache.h @@ -1275,6 +1275,7 @@ extern void close_pack_index(struct packed_git *); extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *); extern void close_pack_windows(struct packed_git *); +extern void close_all_packs(void); extern void unuse_pack(struct pack_window **); extern void free_pack_by_name(const char *); extern void clear_delta_base_cache(void); diff --git a/sha1_file.c b/sha1_file.c index 5d75a327bd..fe823fec3f 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -798,6 +798,22 @@ static int close_pack_fd(struct packed_git *p) return 1; } +static void close_pack(struct packed_git *p) +{ + close_pack_windows(p); + close_pack_fd(p); + close_pack_index(p); +} + +void close_all_packs(void) +{ + struct packed_git *p; + + for (p = packed_git; p; p = p->next) + close_pack(p); +} + + /* * The LRU pack is the one with the oldest MRU window, preferring packs * with no used windows, or the oldest mtime if it has no windows allocated.