git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gc --auto: warn gc will soon run, give users a chance to run manually
@ 2011-11-05 10:33 Nguyễn Thái Ngọc Duy
  2011-11-05 13:39 ` [PATCH] Introduce gc.autowarnonly config option Fernando Vezzosi
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2011-11-05 10:33 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 I hate it every single time git hangs because gc is activated.
 Opening another terminal is an option but I would lose all terminal
 settings I have on the current one (e.g. access to suspended vim
 sessions).

 I don't think gc_warn_* need their own config vars. Hopefully
 hardcoded offset is good enough.

 builtin/gc.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/builtin/gc.c b/builtin/gc.c
index 0498094..1f4555e 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -25,7 +25,9 @@ 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_warn_auto_pack_limit = 45;
 static const char *prune_expire = "2.weeks.ago";
 
 #define MAX_ADD 10
@@ -50,10 +52,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")) {
@@ -118,7 +122,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)
@@ -141,7 +151,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.4.74.g639db

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-03-09 19:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-05 10:33 [PATCH] gc --auto: warn gc will soon run, give users a chance to run manually Nguyễn Thái Ngọc Duy
2011-11-05 13:39 ` [PATCH] Introduce gc.autowarnonly config option Fernando Vezzosi
2011-11-05 10:33   ` [PATCH 2/1] gc --auto: warn gc will soon run, give users a chance to run manually Fernando Vezzosi
2011-11-06  2:47     ` Nguyen Thai Ngoc Duy
2011-11-05 10:33   ` Fernando Vezzosi
2011-11-06  0:19     ` Junio C Hamano
2011-11-05 14:22   ` [PATCH] Introduce gc.autowarnonly config option Sverre Rabbelier
2011-11-07  0:18   ` Jay Soffian
2012-03-09 19:20   ` Sverre Rabbelier
2012-03-09 19:35     ` Junio C Hamano
2011-11-06 16:37 ` [PATCH] gc --auto: warn gc will soon run, give users a chance to run manually Matthieu Moy
2011-11-07  6:04 ` Junio C Hamano
2011-11-07 10:55   ` Nguyen Thai Ngoc Duy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).