summaryrefslogtreecommitdiff
path: root/builtin/gc.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-04-15 15:36:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-16 04:52:29 (GMT)
commit8fc67762471c60ee644e6e100a3a85cf5a8631a0 (patch)
treec40440e93fb21d5aabf9a039cc5266c9cf349b8f /builtin/gc.c
parent55dfe13df9bb38809bc45b8d6d5c7f5bf0470c11 (diff)
downloadgit-8fc67762471c60ee644e6e100a3a85cf5a8631a0.zip
git-8fc67762471c60ee644e6e100a3a85cf5a8631a0.tar.gz
git-8fc67762471c60ee644e6e100a3a85cf5a8631a0.tar.bz2
gc: handle a corner case in gc.bigPackThreshold
This config allows us to keep <N> packs back if their size is larger than a limit. But if this N >= gc.autoPackLimit, we may have a problem. We are supposed to reduce the number of packs after a threshold because it affects performance. We could tell the user that they have incompatible gc.bigPackThreshold and gc.autoPackLimit, but it's kinda hard when 'git gc --auto' runs in background. Instead let's fall back to the next best stategy: try to reduce the number of packs anyway, but keep the base pack out. This reduces the number of packs to two and hopefully won't take up too much resources to repack (the assumption still is the base pack takes most resources to handle). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/gc.c')
-rw-r--r--builtin/gc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index 81ecdc5..23c17ba 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -253,8 +253,14 @@ static int need_to_gc(void)
if (too_many_packs()) {
struct string_list keep_pack = STRING_LIST_INIT_NODUP;
- if (big_pack_threshold)
+ if (big_pack_threshold) {
find_base_packs(&keep_pack, big_pack_threshold);
+ if (keep_pack.nr >= gc_auto_pack_limit) {
+ big_pack_threshold = 0;
+ string_list_clear(&keep_pack, 0);
+ find_base_packs(&keep_pack, 0);
+ }
+ }
add_repack_all_option(&keep_pack);
string_list_clear(&keep_pack, 0);