@matheusbsbs / matheus-bagliano / commits / caf9de2f46
Fork 0

git-gc --auto: move threshold check to need_to_gc() function.

That is where we decide if we are going to run gc automatically. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 17, 2007 at 00:37 UTC caf9de2f46471dc25180bf519c07537c00a68dda
1 file changed +7 -2
builtin-gc.c
+7 -2
@@ -80,6 +80,13 @@ static int need_to_gc(void)
80 int num_loose = 0;
81 int needed = 0;
82
83 + /*
84 + * Setting gc.auto to 0 or negative can disable the
85 + * automatic gc
86 + */
87 + if (gc_auto_threshold <= 0)
88 + return 0;
89 +
90 if (sizeof(path) <= snprintf(path, sizeof(path), "%s/17", objdir)) {
91 warning("insanely long object directory %.*s", 50, objdir);
92 return 0;
@@ -129,8 +136,6 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
136 continue;
137 }
138 if (!strcmp(arg, "--auto")) {
132 - if (gc_auto_threshold <= 0)
133 - return 0;
139 auto_gc = 1;
140 continue;
141 }