Skip to content

Commit 02f6850

Browse files
committed
Add a function to release all packs
On Windows, files that are in use cannot be removed or renamed. That means that we have to release pack files when we are about to, say, repack them. Let's introduce a convenient function to close them pack files. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 821d6ed commit 02f6850

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,7 @@ extern void close_pack_index(struct packed_git *);
12751275

12761276
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
12771277
extern void close_pack_windows(struct packed_git *);
1278+
extern void close_all_packs(void);
12781279
extern void unuse_pack(struct pack_window **);
12791280
extern void free_pack_by_name(const char *);
12801281
extern void clear_delta_base_cache(void);

sha1_file.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,22 @@ static int close_pack_fd(struct packed_git *p)
798798
return 1;
799799
}
800800

801+
static void close_pack(struct packed_git *p)
802+
{
803+
close_pack_windows(p);
804+
close_pack_fd(p);
805+
close_pack_index(p);
806+
}
807+
808+
void close_all_packs(void)
809+
{
810+
struct packed_git *p;
811+
812+
for (p = packed_git; p; p = p->next)
813+
close_pack(p);
814+
}
815+
816+
801817
/*
802818
* The LRU pack is the one with the oldest MRU window, preferring packs
803819
* with no used windows, or the oldest mtime if it has no windows allocated.

0 commit comments

Comments
 (0)