git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/8] git-gc --auto: move threshold check to need_to_gc() function.

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 17, 2007, 08:44 UTC
Message-ID
<1190018703643-git-send-email-gitster@pobox.com>
In-Reply-To
<11900186941912-git-send-email-gitster@pobox.com>

That is where we decide if we are going to run gc automatically.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-gc.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/builtin-gc.c b/builtin-gc.c
index 093b3dd..f046a2a 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -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;
@@ -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;
 		}
-- 
1.5.3.1.967.g6bb01
Previous: Shawn O. PearceNext: Junio C Hamano
Message 7 of 18 in “Export matches_pack_name() and fix its return value”
  1. 1/8 Export matches_pack_name() and fix its return valueJunio C Hamano, Sep 17, 2007
  2. 2/8 pack-objects --keep-unreachableJunio C Hamano, Sep 17, 2007
  3. 3/8 repack -A -d: use --keep-unreachable when repackingJunio C Hamano, Sep 17, 2007
  4. Johannes SchindelinSep 17, 2007
  5. Andreas EricssonSep 17, 2007
  6. Shawn O. PearceSep 18, 2007
  7. 4/8 git-gc --auto: move threshold check to need_to_gc() function.Junio C Hamano, Sep 17, 2007
  8. 5/8 git-gc --auto: add documentation.Junio C Hamano, Sep 17, 2007
  9. Johannes SchindelinSep 17, 2007
  10. Junio C HamanoSep 17, 2007
  11. 6/8 git-gc --auto: protect ourselves from accumulated cruftJunio C Hamano, Sep 17, 2007
  12. 7/8 git-gc --auto: restructure the way "repack" command line is built.Junio C Hamano, Sep 17, 2007
  13. Johannes SchindelinSep 17, 2007
  14. Junio C HamanoSep 17, 2007
  15. 8/8 git-gc --auto: run "repack -A -d -l" as necessary.Junio C Hamano, Sep 17, 2007
  16. Johannes SchindelinSep 17, 2007
  17. Junio C HamanoSep 17, 2007
  18. Shawn O. PearceSep 18, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.