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

[PATCH 2/1] gc --auto: warn gc will soon run, give users a chance to run manually

From
Fernando Vezzosi <buccia@repnz.net>
Date
Nov 5, 2011, 10:33 UTC
Message-ID
<20111105151225.EE3869004A@inscatolati.net>
In-Reply-To
<20111105140529.3A6CE9004A@inscatolati.net>
Signed-off-by: Fernando Vezzosi <buccia@repnz.net>
---
Rebased Nguyễn's patch on top of mine.
 builtin/gc.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index 65b6616..ca620e3 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -25,8 +25,10 @@ static const char * const builtin_gc_usage[] = {
 static int pack_refs = 1;
 static int aggressive_window = 250;
 static int gc_auto_threshold = 6700;
+static int gc_warn_auto_threshold = 6600;
 static int gc_auto_pack_limit = 50;
 static int gc_auto_warn_only = 0;
+static int gc_warn_auto_pack_limit = 45;
 static const char *prune_expire = "2.weeks.ago";
 
 #define MAX_ADD 10
@@ -51,10 +53,12 @@ static int gc_config(const char *var, const char *value, void *cb)
 	}
 	if (!strcmp(var, "gc.auto")) {
 		gc_auto_threshold = git_config_int(var, value);
+		gc_warn_auto_threshold = gc_auto_threshold - 100;
 		return 0;
 	}
 	if (!strcmp(var, "gc.autopacklimit")) {
 		gc_auto_pack_limit = git_config_int(var, value);
+		gc_warn_auto_pack_limit = gc_auto_pack_limit - 5;
 		return 0;
 	}
 	if (!strcmp(var, "gc.pruneexpire")) {
@@ -123,7 +127,13 @@ static int too_many_loose_objects(void)
 		}
 	}
 	closedir(dir);
-	return needed;
+	if (needed)
+		return 1;
+
+	auto_threshold = (gc_warn_auto_threshold + 255) / 256;
+	if (num_loose > auto_threshold)
+		warning(_("Too many loose objects. \"git gc\" will soon run automatically"));
+	return 0;
 }
 
 static int too_many_packs(void)
@@ -146,7 +156,12 @@ static int too_many_packs(void)
 		 */
 		cnt++;
 	}
-	return gc_auto_pack_limit <= cnt;
+	if (gc_auto_pack_limit <= cnt)
+		return 1;
+
+	if (gc_warn_auto_pack_limit <= cnt)
+		warning(_("Too many packs, \"git gc\" will soon run automatically."));
+	return 0;
 }
 
 static int need_to_gc(void)
-- 
1.7.5.3
Previous: Fernando VezzosiNext: Nguyen Thai Ngoc Duy
Message 2 of 9 in “Introduce gc.autowarnonly config option”
  1. Introduce gc.autowarnonly config optionFernando Vezzosi, Nov 5, 2011
  2. 2/1 gc --auto: warn gc will soon run, give users a chance to run manuallyFernando Vezzosi, Nov 5, 2011
  3. Nguyen Thai Ngoc DuyNov 6, 2011
  4. 2/1 gc --auto: warn gc will soon run, give users a chance to run manuallyFernando Vezzosi, Nov 5, 2011
  5. Junio C HamanoNov 6, 2011
  6. Sverre RabbelierNov 5, 2011
  7. Jay SoffianNov 7, 2011
  8. Sverre RabbelierMar 9, 2012
  9. Junio C HamanoMar 9, 2012

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.