Skip to content

Commit

Permalink
git-gc --auto: move threshold check to need_to_gc() function.
Browse files Browse the repository at this point in the history
That is where we decide if we are going to run gc
automatically.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Sep 18, 2007
1 parent 65aa530 commit caf9de2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions builtin-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ static int need_to_gc(void)
int num_loose = 0;
int needed = 0;

/*
* Setting gc.auto to 0 or negative can disable the
* automatic gc
*/
if (gc_auto_threshold <= 0)
return 0;

if (sizeof(path) <= snprintf(path, sizeof(path), "%s/17", objdir)) {
warning("insanely long object directory %.*s", 50, objdir);
return 0;
Expand Down Expand Up @@ -129,8 +136,6 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(arg, "--auto")) {
if (gc_auto_threshold <= 0)
return 0;
auto_gc = 1;
continue;
}
Expand Down

0 comments on commit caf9de2

Please sign in to comment.