{"thread":{"id":"28850","subject":"[PATCH] Introduce gc.autowarnonly config option","startedAt":"2011-11-05T10:33:32Z","lastAt":"2012-03-09T19:35:55Z","messageCount":9,"participants":["Fernando Vezzosi","Sverre Rabbelier","Junio C Hamano","Nguyen Thai Ngoc Duy","Jay Soffian"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"178902","messageId":"20111105151225.EE3869004A@inscatolati.net","threadId":"28850","inReplyTo":"20111105140529.3A6CE9004A@inscatolati.net","subject":"[PATCH 2/1] gc --auto: warn gc will soon run, give users a chance to run manually","fromName":"Fernando Vezzosi","fromEmail":"buccia@repnz.net","sentAt":"2011-11-05T10:33:32Z","receivedAt":"2011-11-05T10:33:32Z","isPatch":true,"sender":{"key":"buccia@repnz.net","avatar":"https://gravatar.com/avatar/67644d6d0b3a1797d9546e07d589fe7ac9351d4b636cc16cb7c13f586aefa51c?d=mp&s=160"},"body":"Signed-off-by: Fernando Vezzosi <buccia@repnz.net>\n---\n\nRebased Nguyễn's patch on top of mine.\n\n builtin/gc.c |   19 +++++++++++++++++--\n 1 files changed, 17 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 65b6616..ca620e3 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -25,8 +25,10 @@ static const char * const builtin_gc_usage[] = {\n static int pack_refs = 1;\n static int aggressive_window = 250;\n static int gc_auto_threshold = 6700;\n+static int gc_warn_auto_threshold = 6600;\n static int gc_auto_pack_limit = 50;\n static int gc_auto_warn_only = 0;\n+static int gc_warn_auto_pack_limit = 45;\n static const char *prune_expire = \"2.weeks.ago\";\n \n #define MAX_ADD 10\n@@ -51,10 +53,12 @@ static int gc_config(const char *var, const char *value, void *cb)\n \t}\n \tif (!strcmp(var, \"gc.auto\")) {\n \t\tgc_auto_threshold = git_config_int(var, value);\n+\t\tgc_warn_auto_threshold = gc_auto_threshold - 100;\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"gc.autopacklimit\")) {\n \t\tgc_auto_pack_limit = git_config_int(var, value);\n+\t\tgc_warn_auto_pack_limit = gc_auto_pack_limit - 5;\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"gc.pruneexpire\")) {\n@@ -123,7 +127,13 @@ static int too_many_loose_objects(void)\n \t\t}\n \t}\n \tclosedir(dir);\n-\treturn needed;\n+\tif (needed)\n+\t\treturn 1;\n+\n+\tauto_threshold = (gc_warn_auto_threshold + 255) / 256;\n+\tif (num_loose > auto_threshold)\n+\t\twarning(_(\"Too many loose objects. \\\"git gc\\\" will soon run automatically\"));\n+\treturn 0;\n }\n \n static int too_many_packs(void)\n@@ -146,7 +156,12 @@ static int too_many_packs(void)\n \t\t */\n \t\tcnt++;\n \t}\n-\treturn gc_auto_pack_limit <= cnt;\n+\tif (gc_auto_pack_limit <= cnt)\n+\t\treturn 1;\n+\n+\tif (gc_warn_auto_pack_limit <= cnt)\n+\t\twarning(_(\"Too many packs, \\\"git gc\\\" will soon run automatically.\"));\n+\treturn 0;\n }\n \n static int need_to_gc(void)\n-- \n1.7.5.3\n"},{"id":"178905","messageId":"20111105154411.079F69004A@inscatolati.net","threadId":"28850","inReplyTo":"20111105140529.3A6CE9004A@inscatolati.net","subject":"[PATCH 2/1] gc --auto: warn gc will soon run, give users a chance to run manually","fromName":"Fernando Vezzosi","fromEmail":"buccia@repnz.net","sentAt":"2011-11-05T10:33:32Z","receivedAt":"2011-11-05T10:33:32Z","isPatch":true,"sender":{"key":"buccia@repnz.net","avatar":"https://gravatar.com/avatar/67644d6d0b3a1797d9546e07d589fe7ac9351d4b636cc16cb7c13f586aefa51c?d=mp&s=160"},"body":"Signed-off-by: Fernando Vezzosi <buccia@repnz.net>\n---\n\nRebased Nguyễn's patch on top of mine.\n\n builtin/gc.c |   19 +++++++++++++++++--\n 1 files changed, 17 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 65b6616..ca620e3 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -25,8 +25,10 @@ static const char * const builtin_gc_usage[] = {\n static int pack_refs = 1;\n static int aggressive_window = 250;\n static int gc_auto_threshold = 6700;\n+static int gc_warn_auto_threshold = 6600;\n static int gc_auto_pack_limit = 50;\n static int gc_auto_warn_only = 0;\n+static int gc_warn_auto_pack_limit = 45;\n static const char *prune_expire = \"2.weeks.ago\";\n \n #define MAX_ADD 10\n@@ -51,10 +53,12 @@ static int gc_config(const char *var, const char *value, void *cb)\n \t}\n \tif (!strcmp(var, \"gc.auto\")) {\n \t\tgc_auto_threshold = git_config_int(var, value);\n+\t\tgc_warn_auto_threshold = gc_auto_threshold - 100;\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"gc.autopacklimit\")) {\n \t\tgc_auto_pack_limit = git_config_int(var, value);\n+\t\tgc_warn_auto_pack_limit = gc_auto_pack_limit - 5;\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"gc.pruneexpire\")) {\n@@ -123,7 +127,13 @@ static int too_many_loose_objects(void)\n \t\t}\n \t}\n \tclosedir(dir);\n-\treturn needed;\n+\tif (needed)\n+\t\treturn 1;\n+\n+\tauto_threshold = (gc_warn_auto_threshold + 255) / 256;\n+\tif (num_loose > auto_threshold)\n+\t\twarning(_(\"Too many loose objects. \\\"git gc\\\" will soon run automatically\"));\n+\treturn 0;\n }\n \n static int too_many_packs(void)\n@@ -146,7 +156,12 @@ static int too_many_packs(void)\n \t\t */\n \t\tcnt++;\n \t}\n-\treturn gc_auto_pack_limit <= cnt;\n+\tif (gc_auto_pack_limit <= cnt)\n+\t\treturn 1;\n+\n+\tif (gc_warn_auto_pack_limit <= cnt)\n+\t\twarning(_(\"Too many packs, \\\"git gc\\\" will soon run automatically.\"));\n+\treturn 0;\n }\n \n static int need_to_gc(void)\n-- \n1.7.5.3\n"},{"id":"178899","messageId":"20111105140529.3A6CE9004A@inscatolati.net","threadId":"28850","inReplyTo":null,"subject":"[PATCH] Introduce gc.autowarnonly config option","fromName":"Fernando Vezzosi","fromEmail":"buccia@repnz.net","sentAt":"2011-11-05T13:39:07Z","receivedAt":"2011-11-05T13:39:07Z","isPatch":true,"sender":{"key":"buccia@repnz.net","avatar":"https://gravatar.com/avatar/67644d6d0b3a1797d9546e07d589fe7ac9351d4b636cc16cb7c13f586aefa51c?d=mp&s=160"},"body":"When `git gc --auto` would detect need for garbage collection to run, it\nwould just run.  With this patch, enabling gc.autowarnonly will instead\nmake it just emit a warning.\n\nReviewed-by: Sverre Rabbelier <srabbelier@gmail.com>\nSigned-off-by: Fernando Vezzosi <buccia@repnz.net>\n---\n builtin/gc.c |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 0498094..65b6616 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -26,6 +26,7 @@ static int pack_refs = 1;\n static int aggressive_window = 250;\n static int gc_auto_threshold = 6700;\n static int gc_auto_pack_limit = 50;\n+static int gc_auto_warn_only = 0;\n static const char *prune_expire = \"2.weeks.ago\";\n \n #define MAX_ADD 10\n@@ -64,6 +65,10 @@ static int gc_config(const char *var, const char *value, void *cb)\n \t\t}\n \t\treturn git_config_string(&prune_expire, var, value);\n \t}\n+\tif (!strcmp(var, \"gc.autowarnonly\")) {\n+\t\tgc_auto_warn_only = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \treturn git_default_config(var, value, cb);\n }\n \n@@ -219,6 +224,15 @@ int cmd_gc(int argc, const char **argv, const char *prefix)\n \t\t */\n \t\tif (!need_to_gc())\n \t\t\treturn 0;\n+\n+\t\tif (gc_auto_warn_only){\n+\t\t\tfprintf(stderr,\n+\t\t\t\t\t_(\"Pack the repository for optimum performance by running\\n\"\n+\t\t\t\t\t\"\\\"git gc\\\" manually. See \"\n+\t\t\t\t\t\"\\\"git help gc\\\" for more information.\\n\"));\n+\t\t\treturn 0;\n+\t\t}\n+\n \t\tif (quiet)\n \t\t\tfprintf(stderr, _(\"Auto packing the repository for optimum performance.\\n\"));\n \t\telse\n-- \n1.7.5.3\n"},{"id":"178901","messageId":"CAGdFq_jQ_2NueWD5YqXb-nuT6boOw66TJ0+m5mFPqenND2RBsQ@mail.gmail.com","threadId":"28850","inReplyTo":"20111105140529.3A6CE9004A@inscatolati.net","subject":"Re: [PATCH] Introduce gc.autowarnonly config option","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2011-11-05T14:22:11Z","receivedAt":"2011-11-05T14:22:11Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sat, Nov 5, 2011 at 14:39, Fernando Vezzosi <buccia@repnz.net> wrote:\n> When `git gc --auto` would detect need for garbage collection to run, it\n> would just run.  With this patch, enabling gc.autowarnonly will instead\n> make it just emit a warning.\n>\n> Reviewed-by: Sverre Rabbelier <srabbelier@gmail.com>\n> Signed-off-by: Fernando Vezzosi <buccia@repnz.net>\n\nHighly relevant considering recent (3 hours ago) patch that instead\nadds a warning that gc will happen soon.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"178936","messageId":"7vaa8a85ma.fsf@alter.siamese.dyndns.org","threadId":"28850","inReplyTo":"20111105154411.079F69004A@inscatolati.net","subject":"Re: [PATCH 2/1] gc --auto: warn gc will soon run, give users a chance to run manually","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-06T00:19:25Z","receivedAt":"2011-11-06T00:19:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fernando Vezzosi <buccia@repnz.net> writes:\n\n> Signed-off-by: Fernando Vezzosi <buccia@repnz.net>\n> ---\n>\n> Rebased Nguyễn's patch on top of mine.\n\nYou don't have to do this.\n"},{"id":"178945","messageId":"CACsJy8DusGtKYWANPFkn9eAp42oe-2uS5b7Rp2oAaNzfUZAB1A@mail.gmail.com","threadId":"28850","inReplyTo":"20111105151225.EE3869004A@inscatolati.net","subject":"Re: [PATCH 2/1] gc --auto: warn gc will soon run, give users a chance to run manually","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-06T02:47:54Z","receivedAt":"2011-11-06T02:47:54Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Nov 5, 2011 at 5:33 PM, Fernando Vezzosi <buccia@repnz.net> wrote:\n> Signed-off-by: Fernando Vezzosi <buccia@repnz.net>\n> ---\n>\n> Rebased Nguyễn's patch on top of mine.\n\nI think when gc.autowarnonly is true, my patch should be no-op because\nyou'll get warnings eventually when you hit the thresholds.\n-- \nDuy\n"},{"id":"178988","messageId":"CAG+J_DzNsAP1xAswkNxTAN6ze8ZV5pFqDMeQXKkjCoQgPUgEQQ@mail.gmail.com","threadId":"28850","inReplyTo":"20111105140529.3A6CE9004A@inscatolati.net","subject":"Re: [PATCH] Introduce gc.autowarnonly config option","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-11-07T00:18:01Z","receivedAt":"2011-11-07T00:18:01Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Sat, Nov 5, 2011 at 9:39 AM, Fernando Vezzosi <buccia@repnz.net> wrote:\n> When `git gc --auto` would detect need for garbage collection to run, it\n> would just run.  With this patch, enabling gc.autowarnonly will instead\n> make it just emit a warning.\n>\n> Reviewed-by: Sverre Rabbelier <srabbelier@gmail.com>\n> Signed-off-by: Fernando Vezzosi <buccia@repnz.net>\n\nThis is much better than the solution I've been living with the last\nyear, which was to put a pre-auto-gc in my templates directory of:\n\n#!/bin/sh\necho \"time to run git gc\"\nexit 1\n\nSo, thank you.\n\nj.\n"},{"id":"186580","messageId":"CAGdFq_g=+A7q7_ZkUYG6LZ+ehLBtMY+s+nJxhp4FVhUQ4Zo_rA@mail.gmail.com","threadId":"28850","inReplyTo":"20111105140529.3A6CE9004A@inscatolati.net","subject":"Re: [PATCH] Introduce gc.autowarnonly config option","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2012-03-09T19:20:36Z","receivedAt":"2012-03-09T19:20:36Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"On Sat, Nov 5, 2011 at 08:39, Fernando Vezzosi <buccia@repnz.net> wrote:\n> When `git gc --auto` would detect need for garbage collection to run, it\n> would just run.  With this patch, enabling gc.autowarnonly will instead\n> make it just emit a warning.\n\nDoes anyone know what happened to this patch?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"186581","messageId":"7veht15zz8.fsf@alter.siamese.dyndns.org","threadId":"28850","inReplyTo":"CAGdFq_g=+A7q7_ZkUYG6LZ+ehLBtMY+s+nJxhp4FVhUQ4Zo_rA@mail.gmail.com","subject":"Re: [PATCH] Introduce gc.autowarnonly config option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-09T19:35:55Z","receivedAt":"2012-03-09T19:35:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sverre Rabbelier <srabbelier@gmail.com> writes:\n\n> On Sat, Nov 5, 2011 at 08:39, Fernando Vezzosi <buccia@repnz.net> wrote:\n>> When `git gc --auto` would detect need for garbage collection to run, it\n>> would just run. With this patch, enabling gc.autowarnonly will instead\n>> make it just emit a warning.\n>\n> Does anyone know what happened to this patch?\n\nIf I recall correctly, it was pointed out that people who would get\nannoyed by unexpected triggering of an auto gc would get annoyed by\nconstant nagging by this warning until they reach the point that\nthey can stop and run gc themselves, and the patch was never updated\nto take that issue into account.\n"}]}