Merge branch 'mr/msvc-link-with-invalidcontinue'
[gitweb.git] / builtin / gc.c
index 63d400bcb2092b1751427994b35057f72b04de17..85f5c2bc62ec1ead593f5aa2e3d7077e65f2f061 100644 (file)
@@ -26,6 +26,7 @@ static const char * const builtin_gc_usage[] = {
 };
 
 static int pack_refs = 1;
+static int aggressive_depth = 250;
 static int aggressive_window = 250;
 static int gc_auto_threshold = 6700;
 static int gc_auto_pack_limit = 50;
@@ -66,6 +67,10 @@ static int gc_config(const char *var, const char *value, void *cb)
                aggressive_window = git_config_int(var, value);
                return 0;
        }
+       if (!strcmp(var, "gc.aggressivedepth")) {
+               aggressive_depth = git_config_int(var, value);
+               return 0;
+       }
        if (!strcmp(var, "gc.auto")) {
                gc_auto_threshold = git_config_int(var, value);
                return 0;
@@ -184,7 +189,7 @@ static int need_to_gc(void)
        else if (!too_many_loose_objects())
                return 0;
 
-       if (run_hook(NULL, "pre-auto-gc", NULL))
+       if (run_hook_le(NULL, "pre-auto-gc", NULL))
                return 0;
        return 1;
 }
@@ -294,7 +299,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 
        if (aggressive) {
                argv_array_push(&repack, "-f");
-               argv_array_push(&repack, "--depth=250");
+               if (aggressive_depth > 0)
+                       argv_array_pushf(&repack, "--depth=%d", aggressive_depth);
                if (aggressive_window > 0)
                        argv_array_pushf(&repack, "--window=%d", aggressive_window);
        }