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

[PATCH] Introduce gc.autowarnonly config option

From
Fernando Vezzosi <buccia@repnz.net>
Date
Nov 5, 2011, 13:39 UTC
Message-ID
<20111105140529.3A6CE9004A@inscatolati.net>

When `git gc --auto` would detect need for garbage collection to run, it would just run. With this patch, enabling gc.autowarnonly will instead make it just emit a warning.

Reviewed-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Fernando Vezzosi <buccia@repnz.net>
---
 builtin/gc.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index 0498094..65b6616 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -26,6 +26,7 @@ static int pack_refs = 1;
 static int aggressive_window = 250;
 static int gc_auto_threshold = 6700;
 static int gc_auto_pack_limit = 50;
+static int gc_auto_warn_only = 0;
 static const char *prune_expire = "2.weeks.ago";
 
 #define MAX_ADD 10
@@ -64,6 +65,10 @@ static int gc_config(const char *var, const char *value, void *cb)
 		}
 		return git_config_string(&prune_expire, var, value);
 	}
+	if (!strcmp(var, "gc.autowarnonly")) {
+		gc_auto_warn_only = git_config_bool(var, value);
+		return 0;
+	}
 	return git_default_config(var, value, cb);
 }
 
@@ -219,6 +224,15 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 		 */
 		if (!need_to_gc())
 			return 0;
+
+		if (gc_auto_warn_only){
+			fprintf(stderr,
+					_("Pack the repository for optimum performance by running\n"
+					"\"git gc\" manually. See "
+					"\"git help gc\" for more information.\n"));
+			return 0;
+		}
+
 		if (quiet)
 			fprintf(stderr, _("Auto packing the repository for optimum performance.\n"));
 		else
-- 
1.7.5.3
Next: Fernando Vezzosi
Message 1 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.