{"thread":{"id":"12924","subject":"[PATCH] git gc --auto: defer on battery","startedAt":"2008-03-30T23:14:08Z","lastAt":"2008-05-15T06:44:40Z","messageCount":27,"participants":["Miklos Vajna","Björn Steinbrink","Johannes Schindelin","Linus Torvalds","Junio C Hamano","Brandon Casey","Joey Hess","Brian Gernhardt","Holger Schurig"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"73376","messageId":"20080330231408.GR11666@genesis","threadId":"12924","inReplyTo":null,"subject":"[PATCH] git gc --auto: defer on battery","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-03-30T23:14:08Z","receivedAt":"2008-03-30T23:14:08Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"This patch modifies git gc --auto so that it will not always repack when\na user is on battery.\n\nIt introduces the new gc.deferonbattery configuration variable, which\ndefaults to true. If it's true and the user is on battery, it will not\nrun git gc --auto.\n\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nIdea is from e2fsprogs, such a repack may take a lot of time and usually\nyou don't have infinite time when you are on battery.. :)\n\nIf the patch looks OK, just it's too late for 1.5.5, then please let me\nknow and I'll resend after 1.5.5.\n\nThanks.\n\n Documentation/git-gc.txt |    4 +++\n builtin-gc.c             |   49 ++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 53 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\nindex d424a4e..7d54148 100644\n--- a/Documentation/git-gc.txt\n+++ b/Documentation/git-gc.txt\n@@ -104,6 +104,10 @@ The optional configuration variable 'gc.pruneExpire' controls how old\n the unreferenced loose objects have to be before they are pruned.  The\n default is \"2 weeks ago\".\n \n+The optional configuration variable 'gc.deferonbattery' determines if\n+`git gc --auto` should be disabled if the system is running on battery.\n+This defaults to true.\n+\n See Also\n --------\n linkgit:git-prune[1]\ndiff --git a/builtin-gc.c b/builtin-gc.c\nindex 8cef36f..7beb046 100644\n--- a/builtin-gc.c\n+++ b/builtin-gc.c\n@@ -23,6 +23,7 @@ static const char * const builtin_gc_usage[] = {\n };\n \n static int pack_refs = 1;\n+static int defer_on_battery = 1;\n static int aggressive_window = -1;\n static int gc_auto_threshold = 6700;\n static int gc_auto_pack_limit = 50;\n@@ -67,6 +68,10 @@ static int gc_config(const char *var, const char *value)\n \t\tprune_expire = xstrdup(value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"gc.deferonbattery\")) {\n+\t\tdefer_on_battery = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \treturn git_default_config(var, value);\n }\n \n@@ -157,6 +162,45 @@ static int too_many_packs(void)\n \treturn gc_auto_pack_limit <= cnt;\n }\n \n+static int is_on_battery(void)\n+{\n+\tFILE *fp;\n+\tDIR *dir;\n+\tchar buf[256], state[256], path[256];\n+\tunsigned int ac = 0;\n+\tstruct dirent* entry;\n+\n+\tif (!defer_on_battery)\n+\t\treturn 0;\n+\n+\tif ((fp = fopen(\"/proc/apm\", \"r\"))) {\n+\t\tif (fscanf(fp, \"%s %s %s %x\", buf, buf, buf, &ac) != 4)\n+\t\t\tac = 1;\n+\t\tfclose(fp);\n+\t\treturn ac != 1;\n+\t}\n+\tif((dir = opendir(\"/proc/acpi/ac_adapter\"))) {\n+\t\twhile ((entry = readdir(dir))) {\n+\t\t\tif (!strcmp(\".\", entry->d_name) || !strcmp(\"..\",\n+\t\t\t\t\t\tentry->d_name))\n+\t\t\t\tcontinue;\n+\t\t\tsnprintf(path, 255, \"/proc/acpi/ac_adapter/%s/state\",\n+\t\t\t\t\tentry->d_name);\n+\t\t\tif ((fp = fopen(path, \"r\"))) {\n+\t\t\t\tif (fscanf(fp, \"%s %s\", buf, state) != 2)\n+\t\t\t\t\tstate[0] = '\\0';\n+\t\t\t\tfclose(fp);\n+\t\t\t\tif (!strncmp(state, \"off-line\", 8)) {\n+\t\t\t\t\tclosedir(dir);\n+\t\t\t\t\treturn 1;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\tclosedir(dir);\n+\t}\n+\treturn 0;\n+}\n+\n static int need_to_gc(void)\n {\n \t/*\n@@ -176,6 +220,11 @@ static int need_to_gc(void)\n \t\tappend_option(argv_repack, \"-A\", MAX_ADD);\n \telse if (!too_many_loose_objects())\n \t\treturn 0;\n+\n+\tif(is_on_battery()) {\n+\t\tfprintf(stderr, \"Auto packing deferred; on battery\");\n+\t\treturn 0;\n+\t}\n \treturn 1;\n }\n \n-- \n1.5.4.5\n"},{"id":"73377","messageId":"20080330232612.GA23063@atjola.homenet","threadId":"12924","inReplyTo":"20080330231408.GR11666@genesis","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-03-30T23:26:12Z","receivedAt":"2008-03-30T23:26:12Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.03.31 01:14:08 +0200, Miklos Vajna wrote:\n> This patch modifies git gc --auto so that it will not always repack when\n> a user is on battery.\n> \n> It introduces the new gc.deferonbattery configuration variable, which\n> defaults to true. If it's true and the user is on battery, it will not\n> run git gc --auto.\n> \n> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n> ---\n> \n> Idea is from e2fsprogs, such a repack may take a lot of time and usually\n> you don't have infinite time when you are on battery.. :)\n> \n> If the patch looks OK, just it's too late for 1.5.5, then please let me\n> know and I'll resend after 1.5.5.\n> \n> Thanks.\n> \n>  Documentation/git-gc.txt |    4 +++\n>  builtin-gc.c             |   49 ++++++++++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 53 insertions(+), 0 deletions(-)\n> \n> diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\n> index d424a4e..7d54148 100644\n> --- a/Documentation/git-gc.txt\n> +++ b/Documentation/git-gc.txt\n> @@ -104,6 +104,10 @@ The optional configuration variable 'gc.pruneExpire' controls how old\n>  the unreferenced loose objects have to be before they are pruned.  The\n>  default is \"2 weeks ago\".\n>  \n> +The optional configuration variable 'gc.deferonbattery' determines if\n> +`git gc --auto` should be disabled if the system is running on battery.\n> +This defaults to true.\n> +\n>  See Also\n>  --------\n>  linkgit:git-prune[1]\n> diff --git a/builtin-gc.c b/builtin-gc.c\n> index 8cef36f..7beb046 100644\n> --- a/builtin-gc.c\n> +++ b/builtin-gc.c\n> @@ -23,6 +23,7 @@ static const char * const builtin_gc_usage[] = {\n>  };\n>  \n>  static int pack_refs = 1;\n> +static int defer_on_battery = 1;\n>  static int aggressive_window = -1;\n>  static int gc_auto_threshold = 6700;\n>  static int gc_auto_pack_limit = 50;\n> @@ -67,6 +68,10 @@ static int gc_config(const char *var, const char *value)\n>  \t\tprune_expire = xstrdup(value);\n>  \t\treturn 0;\n>  \t}\n> +\tif (!strcmp(var, \"gc.deferonbattery\")) {\n> +\t\tdefer_on_battery = git_config_bool(var, value);\n> +\t\treturn 0;\n> +\t}\n>  \treturn git_default_config(var, value);\n>  }\n>  \n> @@ -157,6 +162,45 @@ static int too_many_packs(void)\n>  \treturn gc_auto_pack_limit <= cnt;\n>  }\n>  \n> +static int is_on_battery(void)\n> +{\n> +\tFILE *fp;\n> +\tDIR *dir;\n> +\tchar buf[256], state[256], path[256];\n> +\tunsigned int ac = 0;\n> +\tstruct dirent* entry;\n> +\n> +\tif (!defer_on_battery)\n> +\t\treturn 0;\n\nHm, maybe move that check into need_to_gc instead? Seems a bit weird to\nlie about the status instead of just skipping the status check.\n\n> +\n> +\tif ((fp = fopen(\"/proc/apm\", \"r\"))) {\n> +\t\tif (fscanf(fp, \"%s %s %s %x\", buf, buf, buf, &ac) != 4)\n> +\t\t\tac = 1;\n> +\t\tfclose(fp);\n> +\t\treturn ac != 1;\n> +\t}\n> +\tif((dir = opendir(\"/proc/acpi/ac_adapter\"))) {\n> +\t\twhile ((entry = readdir(dir))) {\n> +\t\t\tif (!strcmp(\".\", entry->d_name) || !strcmp(\"..\",\n> +\t\t\t\t\t\tentry->d_name))\n> +\t\t\t\tcontinue;\n> +\t\t\tsnprintf(path, 255, \"/proc/acpi/ac_adapter/%s/state\",\n> +\t\t\t\t\tentry->d_name);\n> +\t\t\tif ((fp = fopen(path, \"r\"))) {\n> +\t\t\t\tif (fscanf(fp, \"%s %s\", buf, state) != 2)\n> +\t\t\t\t\tstate[0] = '\\0';\n> +\t\t\t\tfclose(fp);\n> +\t\t\t\tif (!strncmp(state, \"off-line\", 8)) {\n> +\t\t\t\t\tclosedir(dir);\n> +\t\t\t\t\treturn 1;\n> +\t\t\t\t}\n> +\t\t\t}\n> +\t\t}\n> +\t\tclosedir(dir);\n> +\t}\n> +\treturn 0;\n> +}\n\nThe /proc stuff is already deprecated IIRC, the new file to check on\nLinux is /sys/class/power_supply/AC/online.\n\nBjörn\n\n> +\n>  static int need_to_gc(void)\n>  {\n>  \t/*\n> @@ -176,6 +220,11 @@ static int need_to_gc(void)\n>  \t\tappend_option(argv_repack, \"-A\", MAX_ADD);\n>  \telse if (!too_many_loose_objects())\n>  \t\treturn 0;\n> +\n> +\tif(is_on_battery()) {\n> +\t\tfprintf(stderr, \"Auto packing deferred; on battery\");\n> +\t\treturn 0;\n> +\t}\n>  \treturn 1;\n>  }\n>  \n"},{"id":"73378","messageId":"20080330233916.GU11666@genesis","threadId":"12924","inReplyTo":"20080330232612.GA23063@atjola.homenet","subject":"[PATCH] git gc --auto: defer on battery","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-03-30T23:39:16Z","receivedAt":"2008-03-30T23:39:16Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"This patch modifies git gc --auto so that it will not always repack when\na user is on battery.\n\nIt introduces the new gc.deferonbattery configuration variable, which\ndefaults to true. If it's true and the user is on battery, it will not\nrun git gc --auto.\n\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nOn Mon, Mar 31, 2008 at 01:26:12AM +0200, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n> Hm, maybe move that check into need_to_gc instead? Seems a bit weird\n> to\n> lie about the status instead of just skipping the status check.\n\nRight, I've moved the check to need_to_gc().\n\n> The /proc stuff is already deprecated IIRC, the new file to check on\n> Linux is /sys/class/power_supply/AC/online.\n\nAnd that makes the patch smaller as well. :)\n\nSomething like this?\n\n Documentation/git-gc.txt |    4 ++++\n builtin-gc.c             |   24 ++++++++++++++++++++++++\n 2 files changed, 28 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\nindex d424a4e..7d54148 100644\n--- a/Documentation/git-gc.txt\n+++ b/Documentation/git-gc.txt\n@@ -104,6 +104,10 @@ The optional configuration variable 'gc.pruneExpire' controls how old\n the unreferenced loose objects have to be before they are pruned.  The\n default is \"2 weeks ago\".\n \n+The optional configuration variable 'gc.deferonbattery' determines if\n+`git gc --auto` should be disabled if the system is running on battery.\n+This defaults to true.\n+\n See Also\n --------\n linkgit:git-prune[1]\ndiff --git a/builtin-gc.c b/builtin-gc.c\nindex 8cef36f..512a357 100644\n--- a/builtin-gc.c\n+++ b/builtin-gc.c\n@@ -23,6 +23,7 @@ static const char * const builtin_gc_usage[] = {\n };\n \n static int pack_refs = 1;\n+static int defer_on_battery = 1;\n static int aggressive_window = -1;\n static int gc_auto_threshold = 6700;\n static int gc_auto_pack_limit = 50;\n@@ -67,6 +68,10 @@ static int gc_config(const char *var, const char *value)\n \t\tprune_expire = xstrdup(value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"gc.deferonbattery\")) {\n+\t\tdefer_on_battery = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \treturn git_default_config(var, value);\n }\n \n@@ -157,6 +162,20 @@ static int too_many_packs(void)\n \treturn gc_auto_pack_limit <= cnt;\n }\n \n+static int is_on_battery(void)\n+{\n+\tFILE *fp;\n+\tunsigned int state = 1;\n+\n+\tif ((fp = fopen(\"/sys/class/power_supply/AC/online\", \"r\"))) {\n+\t\tif (fscanf(fp, \"%d\", &state) != 1)\n+\t\t\tstate = 1;\n+\t\tfclose(fp);\n+\t\treturn state != 1;\n+\t}\n+\treturn 0;\n+}\n+\n static int need_to_gc(void)\n {\n \t/*\n@@ -176,6 +195,11 @@ static int need_to_gc(void)\n \t\tappend_option(argv_repack, \"-A\", MAX_ADD);\n \telse if (!too_many_loose_objects())\n \t\treturn 0;\n+\n+\tif(defer_on_battery && is_on_battery()) {\n+\t\tfprintf(stderr, \"Auto packing deferred; on battery\");\n+\t\treturn 0;\n+\t}\n \treturn 1;\n }\n \n-- \n1.5.4.5\n"},{"id":"73379","messageId":"alpine.LSU.1.00.0803310137090.18259@racer.site","threadId":"12924","inReplyTo":"20080330231408.GR11666@genesis","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-30T23:41:18Z","receivedAt":"2008-03-30T23:41:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 31 Mar 2008, Miklos Vajna wrote:\n\n> +\tif ((fp = fopen(\"/proc/apm\", \"r\"))) {\n> +\t\tif (fscanf(fp, \"%s %s %s %x\", buf, buf, buf, &ac) != 4)\n> +\t\t\tac = 1;\n> +\t\tfclose(fp);\n> +\t\treturn ac != 1;\n> +\t}\n\nIf /proc/apm could be opened, should you still try to open \n/proc/acpi/ac_adapter?\n\nAnd what about system dependency?  I mean, if at all, this stuff belongs \nto compat/.  Definitely not into builtin-gc.c.  And yes, that means that \nyou should not call the function is_on_battery() blindly, but _only_ if \ndefer_on_battery is set.\n\nCiao,\nDscho\n> @@ -176,6 +220,11 @@ static int need_to_gc(void)\n>  \t\tappend_option(argv_repack, \"-A\", MAX_ADD);\n>  \telse if (!too_many_loose_objects())\n>  \t\treturn 0;\n> +\n> +\tif(is_on_battery()) {\n\nStyle.  As can be seen 3 lines earlier, we put a space after the \"if\".\n\nCiao,\nDscho\n"},{"id":"73381","messageId":"alpine.LFD.1.00.0803301645020.14670@woody.linux-foundation.org","threadId":"12924","inReplyTo":"20080330232612.GA23063@atjola.homenet","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-03-30T23:46:51Z","receivedAt":"2008-03-30T23:46:51Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 31 Mar 2008, Bj?rn Steinbrink wrote:\n> \n> The /proc stuff is already deprecated IIRC, the new file to check on\n> Linux is /sys/class/power_supply/AC/online.\n\nI would *seriously* suggest making this soem kind of generic callback and \nnot Linux-specific. \n\nHow about making it more akin to a pre-auto-gc \"hook\" - run a script \ninstead of hardcoding something like this!\n\n\t\tLinus\n"},{"id":"73384","messageId":"20080330235322.GV11666@genesis","threadId":"12924","inReplyTo":"alpine.LSU.1.00.0803310137090.18259@racer.site","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-03-30T23:53:22Z","receivedAt":"2008-03-30T23:53:22Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Mon, Mar 31, 2008 at 01:41:18AM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> And what about system dependency?  I mean, if at all, this stuff belongs \n> to compat/.  Definitely not into builtin-gc.c.  And yes, that means that \n> you should not call the function is_on_battery() blindly, but _only_ if \n> defer_on_battery is set.\n\nHm, should I just move it to there or should there be some kind of\ncheck? Currently it just tries to open that file under /sys and if\nfails, it just assumes we are not on battery. I think that's the\nexpected behaviour on systems not having a /sys filesystem.\n\nAs far as I see, compat/ is for functions which are available on some\nsystems but not an all ones. Obviously is_on_battery() won't be available\non any system. :)\n\nThe other issues (I hope) are fixed in the second patch.\n"},{"id":"73385","messageId":"20080330235513.GA23259@atjola.homenet","threadId":"12924","inReplyTo":"20080330233916.GU11666@genesis","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-03-30T23:55:13Z","receivedAt":"2008-03-30T23:55:13Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.03.31 01:39:16 +0200, Miklos Vajna wrote:\n> This patch modifies git gc --auto so that it will not always repack when\n> a user is on battery.\n> \n> It introduces the new gc.deferonbattery configuration variable, which\n> defaults to true. If it's true and the user is on battery, it will not\n> run git gc --auto.\n> \n> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n> ---\n> \n> On Mon, Mar 31, 2008 at 01:26:12AM +0200, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n> > Hm, maybe move that check into need_to_gc instead? Seems a bit weird\n> > to\n> > lie about the status instead of just skipping the status check.\n> \n> Right, I've moved the check to need_to_gc().\n> \n> > The /proc stuff is already deprecated IIRC, the new file to check on\n> > Linux is /sys/class/power_supply/AC/online.\n> \n> And that makes the patch smaller as well. :)\n\nOh, oops, I didn't meant to say that you should remove the /proc/*\nchecks, just that they'll probably break in the future and that the new\nlocation needs to be added. Those running older kernels should probably\nnot be excluded ;-)\n\nBjörn\n\n> Something like this?\n> \n>  Documentation/git-gc.txt |    4 ++++\n>  builtin-gc.c             |   24 ++++++++++++++++++++++++\n>  2 files changed, 28 insertions(+), 0 deletions(-)\n> \n> diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\n> index d424a4e..7d54148 100644\n> --- a/Documentation/git-gc.txt\n> +++ b/Documentation/git-gc.txt\n> @@ -104,6 +104,10 @@ The optional configuration variable 'gc.pruneExpire' controls how old\n>  the unreferenced loose objects have to be before they are pruned.  The\n>  default is \"2 weeks ago\".\n>  \n> +The optional configuration variable 'gc.deferonbattery' determines if\n> +`git gc --auto` should be disabled if the system is running on battery.\n> +This defaults to true.\n> +\n>  See Also\n>  --------\n>  linkgit:git-prune[1]\n> diff --git a/builtin-gc.c b/builtin-gc.c\n> index 8cef36f..512a357 100644\n> --- a/builtin-gc.c\n> +++ b/builtin-gc.c\n> @@ -23,6 +23,7 @@ static const char * const builtin_gc_usage[] = {\n>  };\n>  \n>  static int pack_refs = 1;\n> +static int defer_on_battery = 1;\n>  static int aggressive_window = -1;\n>  static int gc_auto_threshold = 6700;\n>  static int gc_auto_pack_limit = 50;\n> @@ -67,6 +68,10 @@ static int gc_config(const char *var, const char *value)\n>  \t\tprune_expire = xstrdup(value);\n>  \t\treturn 0;\n>  \t}\n> +\tif (!strcmp(var, \"gc.deferonbattery\")) {\n> +\t\tdefer_on_battery = git_config_bool(var, value);\n> +\t\treturn 0;\n> +\t}\n>  \treturn git_default_config(var, value);\n>  }\n>  \n> @@ -157,6 +162,20 @@ static int too_many_packs(void)\n>  \treturn gc_auto_pack_limit <= cnt;\n>  }\n>  \n> +static int is_on_battery(void)\n> +{\n> +\tFILE *fp;\n> +\tunsigned int state = 1;\n> +\n> +\tif ((fp = fopen(\"/sys/class/power_supply/AC/online\", \"r\"))) {\n> +\t\tif (fscanf(fp, \"%d\", &state) != 1)\n> +\t\t\tstate = 1;\n> +\t\tfclose(fp);\n> +\t\treturn state != 1;\n> +\t}\n> +\treturn 0;\n> +}\n> +\n>  static int need_to_gc(void)\n>  {\n>  \t/*\n> @@ -176,6 +195,11 @@ static int need_to_gc(void)\n>  \t\tappend_option(argv_repack, \"-A\", MAX_ADD);\n>  \telse if (!too_many_loose_objects())\n>  \t\treturn 0;\n> +\n> +\tif(defer_on_battery && is_on_battery()) {\n> +\t\tfprintf(stderr, \"Auto packing deferred; on battery\");\n> +\t\treturn 0;\n> +\t}\n>  \treturn 1;\n>  }\n>  \n"},{"id":"73386","messageId":"20080331000012.GB23259@atjola.homenet","threadId":"12924","inReplyTo":"alpine.LFD.1.00.0803301645020.14670@woody.linux-foundation.org","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-03-31T00:00:12Z","receivedAt":"2008-03-31T00:00:12Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.03.30 16:46:51 -0700, Linus Torvalds wrote:\n> \n> \n> On Mon, 31 Mar 2008, Bj?rn Steinbrink wrote:\n> > \n> > The /proc stuff is already deprecated IIRC, the new file to check on\n> > Linux is /sys/class/power_supply/AC/online.\n> \n> I would *seriously* suggest making this soem kind of generic callback and \n> not Linux-specific. \n\nI didn't meant to make that Linux-specific, I just wanted to mention\nthat the /proc stuff might break rather \"soon\", and that the code should\nalso check the the sysfs stuff.\n\n> How about making it more akin to a pre-auto-gc \"hook\" - run a script \n> instead of hardcoding something like this!\n\nSounds nice.\n\nBjörn\n"},{"id":"73395","messageId":"7vr6drsl47.fsf@gitster.siamese.dyndns.org","threadId":"12924","inReplyTo":"alpine.LFD.1.00.0803301645020.14670@woody.linux-foundation.org","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-31T02:06:16Z","receivedAt":"2008-03-31T02:06:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> On Mon, 31 Mar 2008, Bj?rn Steinbrink wrote:\n>> \n>> The /proc stuff is already deprecated IIRC, the new file to check on\n>> Linux is /sys/class/power_supply/AC/online.\n>\n> I would *seriously* suggest making this soem kind of generic callback and \n> not Linux-specific. \n>\n> How about making it more akin to a pre-auto-gc \"hook\" - run a script \n> instead of hardcoding something like this!\n\nThat would be a sensible approach.\n\nWe also would need to make sure that Porcelain that call \"gc --auto\" does\nnot have an assumption that auto is ultra-cheap, however, as we are\ntalking about potentially two fork-exec in the usual \"noop\" case with such\na change, but we need to do that regardless.\n\n * git-svn has \"every 1000 commits and one at the end\" which should be\n   Ok.\n\n * git-cvsimport does \"repack -a -d\" every 1k commits and once more at the\n   end if there are many remaining loose objects.\n\n * \"git-rebase -i\" does one at the end, which should be Ok.\n\n * \"git commit\" used to have one at the end in the scripted version, but\n   seems to have lost it in C rewrite.\n\nSo I think we are Ok with an additional hook.\n\nBy the way, Linus, is your MUA UTF-8 challenged?  I see Björn's name on\nthe To: header mangled.\n"},{"id":"73426","messageId":"cover.1206929014.git.vmiklos@frugalware.org","threadId":"12924","inReplyTo":"alpine.LFD.1.00.0803301645020.14670@woody.linux-foundation.org","subject":"[PATCH 0/4] add pre-auto-gc hook for git-gc --auto","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-03-31T09:35:27Z","receivedAt":"2008-03-31T09:35:27Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Sun, Mar 30, 2008 at 04:46:51PM -0700, Linus Torvalds <torvalds@linux-foundation.org> wrote:\n> How about making it more akin to a pre-auto-gc \"hook\" - run a script\n> instead of hardcoding something like this!\n\nSomething like this?\n\nMiklos Vajna (4):\n  git-gc --auto: add pre-auto-gc hook\n  git-gc: add a --no-verify option to bypass the pre-auto-gc hook\n  Documentation/hooks: add pre-auto-gc hook\n  templates: add an example pre-auto-gc hook\n\n Documentation/git-gc.txt     |    4 ++++\n Documentation/hooks.txt      |   10 ++++++++++\n builtin-gc.c                 |   24 ++++++++++++++++++++++++\n templates/hooks--pre-auto-gc |   29 +++++++++++++++++++++++++++++\n 4 files changed, 67 insertions(+), 0 deletions(-)\n create mode 100644 templates/hooks--pre-auto-gc\n"},{"id":"73427","messageId":"7637ee64f43964d2e514c1598b2e7783d71b8608.1206929014.git.vmiklos@frugalware.org","threadId":"12924","inReplyTo":"alpine.LFD.1.00.0803301645020.14670@woody.linux-foundation.org","subject":"[PATCH 1/4] git-gc --auto: add pre-auto-gc hook","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-03-31T09:35:46Z","receivedAt":"2008-03-31T09:35:46Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"If such a hook is available and exits with a non-zero status, then\ngit-gc --auto won't run.\n\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n builtin-gc.c |   22 ++++++++++++++++++++++\n 1 files changed, 22 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-gc.c b/builtin-gc.c\nindex 8cef36f..acd63be 100644\n--- a/builtin-gc.c\n+++ b/builtin-gc.c\n@@ -157,6 +157,25 @@ static int too_many_packs(void)\n \treturn gc_auto_pack_limit <= cnt;\n }\n \n+static int run_hook()\n+{\n+\tconst char *argv[2];\n+\tstruct child_process hook;\n+\n+\targv[0] = git_path(\"hooks/pre-auto-gc\");\n+\targv[1] = NULL;\n+\n+\tif (access(argv[0], X_OK) < 0)\n+\t\treturn 0;\n+\n+\tmemset(&hook, 0, sizeof(hook));\n+\thook.argv = argv;\n+\thook.no_stdin = 1;\n+\thook.stdout_to_stderr = 1;\n+\n+\treturn run_command(&hook);\n+}\n+\n static int need_to_gc(void)\n {\n \t/*\n@@ -176,6 +195,9 @@ static int need_to_gc(void)\n \t\tappend_option(argv_repack, \"-A\", MAX_ADD);\n \telse if (!too_many_loose_objects())\n \t\treturn 0;\n+\n+\tif (run_hook())\n+\t\treturn 0;\n \treturn 1;\n }\n \n-- \n1.5.5.rc2.4.g283c6\n"},{"id":"73428","messageId":"e755e3fd6b48cd43c61ae6c0c610aaa7b5e166f0.1206929014.git.vmiklos@frugalware.org","threadId":"12924","inReplyTo":"alpine.LFD.1.00.0803301645020.14670@woody.linux-foundation.org","subject":"[PATCH 2/4] git-gc: add a --no-verify option to bypass the pre-auto-gc hook","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-03-31T09:36:13Z","receivedAt":"2008-03-31T09:36:13Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n Documentation/git-gc.txt |    4 ++++\n builtin-gc.c             |    4 +++-\n 2 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\nindex d424a4e..396da5c 100644\n--- a/Documentation/git-gc.txt\n+++ b/Documentation/git-gc.txt\n@@ -62,6 +62,10 @@ automatic consolidation of packs.\n --quiet::\n \tSuppress all progress reports.\n \n+--no-verify::\n+\tThis option bypasses the pre-auto-gc hook.\n+\tSee also link:hooks.html[hooks].\n+\n Configuration\n -------------\n \ndiff --git a/builtin-gc.c b/builtin-gc.c\nindex acd63be..1eca6b2 100644\n--- a/builtin-gc.c\n+++ b/builtin-gc.c\n@@ -27,6 +27,7 @@ static int aggressive_window = -1;\n static int gc_auto_threshold = 6700;\n static int gc_auto_pack_limit = 50;\n static char *prune_expire = \"2.weeks.ago\";\n+static int no_verify;\n \n #define MAX_ADD 10\n static const char *argv_pack_refs[] = {\"pack-refs\", \"--all\", \"--prune\", NULL};\n@@ -196,7 +197,7 @@ static int need_to_gc(void)\n \telse if (!too_many_loose_objects())\n \t\treturn 0;\n \n-\tif (run_hook())\n+\tif (!no_verify && run_hook())\n \t\treturn 0;\n \treturn 1;\n }\n@@ -214,6 +215,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOLEAN(0, \"aggressive\", &aggressive, \"be more thorough (increased runtime)\"),\n \t\tOPT_BOOLEAN(0, \"auto\", &auto_gc, \"enable auto-gc mode\"),\n \t\tOPT_BOOLEAN('q', \"quiet\", &quiet, \"suppress progress reports\"),\n+\t\tOPT_BOOLEAN('n', \"no-verify\", &no_verify, \"bypass pre-auto-gc hook\"),\n \t\tOPT_END()\n \t};\n \n-- \n1.5.5.rc2.4.g283c6\n"},{"id":"73429","messageId":"0a4fb03744d2a8c3e38030a29098e25823aed6bc.1206929014.git.vmiklos@frugalware.org","threadId":"12924","inReplyTo":"alpine.LFD.1.00.0803301645020.14670@woody.linux-foundation.org","subject":"[PATCH 3/4] Documentation/hooks: add pre-auto-gc hook","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-03-31T09:36:44Z","receivedAt":"2008-03-31T09:36:44Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n Documentation/hooks.txt |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/hooks.txt b/Documentation/hooks.txt\nindex 76b8d77..04ec352 100644\n--- a/Documentation/hooks.txt\n+++ b/Documentation/hooks.txt\n@@ -276,3 +276,13 @@ probably enable this hook.\n Both standard output and standard error output are forwarded to\n `git-send-pack` on the other end, so you can simply `echo` messages\n for the user.\n+\n+pre-auto-gc\n+-----------\n+\n+This hook is invoked by `git-gc --auto`, and can be bypassed with\n+`\\--no-verify` option.  It takes no parameter, and exiting with non-zero\n+status from this script causes the `git-gc --auto` to abort.\n+\n+The default 'pre-auto-gc' hook, when enabled, defers auto repacking when\n+you are on battery.\n-- \n1.5.5.rc2.4.g283c6\n"},{"id":"73430","messageId":"283c63fb960d36a322b45fac97804af18a9e5abe.1206929014.git.vmiklos@frugalware.org","threadId":"12924","inReplyTo":"alpine.LFD.1.00.0803301645020.14670@woody.linux-foundation.org","subject":"[PATCH 4/4] templates: add an example pre-auto-gc hook","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-03-31T09:37:22Z","receivedAt":"2008-03-31T09:37:22Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"It disabled git-gc --auto when you are on battery.\n\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n templates/hooks--pre-auto-gc |   29 +++++++++++++++++++++++++++++\n 1 files changed, 29 insertions(+), 0 deletions(-)\n create mode 100644 templates/hooks--pre-auto-gc\n\ndiff --git a/templates/hooks--pre-auto-gc b/templates/hooks--pre-auto-gc\nnew file mode 100644\nindex 0000000..40c4759\n--- /dev/null\n+++ b/templates/hooks--pre-auto-gc\n@@ -0,0 +1,29 @@\n+#!/bin/sh\n+#\n+# An example hook script to verify if you are on battery.  Called by\n+# git-gc --auto with no arguments.  The hook should exit with non-zero\n+# status after issuing an appropriate message if it wants to stop the\n+# auto repacking.\n+#\n+# To enable this hook, make this file executable.\n+\n+defer=0\n+\n+if [ -e /sys/class/power_supply/AC/online ]; then\n+\tif [ \"`cat /sys/class/power_supply/AC/online`\" = 0 ]; then\n+\t\tdefer=1\n+\tfi\n+elif [ -e /proc/acpi/ac_adapter/AC/state ]; then\n+\tif grep -q 'off-line' /proc/acpi/ac_adapter/AC/state; then\n+\t\tdefer=1\n+\tfi\n+elif [ -e /proc/apm ]; then\n+\tif grep -q '0$' /proc/apm; then\n+\t\tdefer=1\n+\tfi\n+fi\n+\n+if [ \"$defer\" = 1 ]; then\n+\techo \"Auto packing deferred; on battery\"\n+\texit 1\n+fi\n-- \n1.5.5.rc2.4.g283c6\n"},{"id":"73437","messageId":"alpine.LFD.1.00.0803310757550.14670@woody.linux-foundation.org","threadId":"12924","inReplyTo":"7vr6drsl47.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-03-31T15:02:51Z","receivedAt":"2008-03-31T15:02:51Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 30 Mar 2008, Junio C Hamano wrote:\n> \n> By the way, Linus, is your MUA UTF-8 challenged?  I see Björn's name on\n> the To: header mangled.\n\nMy MUA is not utf-8 challenged per se, but it doesn't seem to like Björn's \nheaders.\n\nFor example, I see \"しらいしななこ <nanako3@bluebottle.com>\" perfectly \ncorrectly (Content-Type: text/plain; charset=UTF-8), but Björn's emails \ntend to be (Content-Type: text/plain; charset=iso-8859-1) but then he has \nhis email address in utf-8, and that seems to be what makes my MUA \nunhappy about it.\n\n\t\t\tLinus\n"},{"id":"73442","messageId":"47F11036.1000809@nrlssc.navy.mil","threadId":"12924","inReplyTo":"20080330231408.GR11666@genesis","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-03-31T16:24:22Z","receivedAt":"2008-03-31T16:24:22Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Miklos Vajna wrote:\n> This patch modifies git gc --auto so that it will not always repack when\n> a user is on battery.\n> \n> It introduces the new gc.deferonbattery configuration variable,\n\nShouldn't the config option have 'auto' in the name? Or in some way convey\nthat this is _only_ about deferring automatic gc'ing?\n\n-brandon\n"},{"id":"73443","messageId":"20080331164328.GA31518@atjola.homenet","threadId":"12924","inReplyTo":"alpine.LFD.1.00.0803310757550.14670@woody.linux-foundation.org","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-03-31T16:43:28Z","receivedAt":"2008-03-31T16:43:28Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.03.31 08:02:51 -0700, Linus Torvalds wrote:\n> \n> \n> On Sun, 30 Mar 2008, Junio C Hamano wrote:\n> > \n> > By the way, Linus, is your MUA UTF-8 challenged?  I see Björn's name on\n> > the To: header mangled.\n> \n> My MUA is not utf-8 challenged per se, but it doesn't seem to like Björn's \n> headers.\n> \n> For example, I see \"しらいしななこ <nanako3@bluebottle.com>\" perfectly \n> correctly (Content-Type: text/plain; charset=UTF-8), but Björn's emails \n> tend to be (Content-Type: text/plain; charset=iso-8859-1) but then he has \n> his email address in utf-8, and that seems to be what makes my MUA \n> unhappy about it.\n\nHm, that's weird. My header shows my name as iso-8859-1, same as the\nbody. I checked the copy that I got from the list to eliminate any weird\nlocal-copy effects.\n\nFrom:\t=?iso-8859-1?Q?Bj=F6rn?= Steinbrink <B.Steinbrink@gmx.de>\n\nSo maybe your MUA is iso-8859-1 challenged instead? I'll send this one\nout as UTF-8.\n\nBjörn\n"},{"id":"73444","messageId":"alpine.LFD.1.00.0803310953030.14670@woody.linux-foundation.org","threadId":"12924","inReplyTo":"20080331164328.GA31518@atjola.homenet","subject":"fetchmail (Re: [PATCH] git gc --auto: defer on battery)","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-03-31T17:00:30Z","receivedAt":"2008-03-31T17:00:30Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 31 Mar 2008, Bj?rn Steinbrink wrote:\n> \n> Hm, that's weird. My header shows my name as iso-8859-1, same as the\n> body. I checked the copy that I got from the list to eliminate any weird\n> local-copy effects.\n> \n> From:\t=?iso-8859-1?Q?Bj=F6rn?= Steinbrink <B.Steinbrink@gmx.de>\n> \n> So maybe your MUA is iso-8859-1 challenged instead? I'll send this one\n> out as UTF-8.\n\nAhhah! That's it. Not my MUA, but I'm using fetchmail, and I have copied \nmy .fetchmailrc file around for years. As a result, it has 'mimedecode' \nset, because pine used to be really bad at this and obviously all my \noriginal BK (and later git) email scripts didn't do mime decoding either.\n\nSo what is probably happening is that my fetchmail setup dropped the \ncharset information for the header (this is documented by fetchmail, so \nit's not a bug, it's just part of the rules) and just turned it into the \nraw byte sequence.\n\nI've turned off mimedecode, can you send another email to me (in private) \nto see if not doing that just fixes things?\n\n\t\t\tLinus\n"},{"id":"73446","messageId":"20080331173801.GD10018@genesis.frugalware.org","threadId":"12924","inReplyTo":"47F11036.1000809@nrlssc.navy.mil","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-03-31T17:38:02Z","receivedAt":"2008-03-31T17:38:02Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Mon, Mar 31, 2008 at 11:24:22AM -0500, Brandon Casey <casey@nrlssc.navy.mil> wrote:\n> Miklos Vajna wrote:\n> > This patch modifies git gc --auto so that it will not always repack when\n> > a user is on battery.\n> > \n> > It introduces the new gc.deferonbattery configuration variable,\n> \n> Shouldn't the config option have 'auto' in the name? Or in some way convey\n> that this is _only_ about deferring automatic gc'ing?\n\nThat makes sense. Though this patch isn't OK, see my other patch series\nin this thread (the pre-auto-gc hook has no config name).\n"},{"id":"73447","messageId":"20080331180831.GA14916@kodama.kitenet.net","threadId":"12924","inReplyTo":"alpine.LFD.1.00.0803301645020.14670@woody.linux-foundation.org","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2008-03-31T18:08:31Z","receivedAt":"2008-03-31T18:08:31Z","isPatch":true,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"Linus Torvalds wrote:\n> I would *seriously* suggest making this soem kind of generic callback and \n> not Linux-specific. \n> \n> How about making it more akin to a pre-auto-gc \"hook\" - run a script \n> instead of hardcoding something like this!\n\nFWIW, Debian (and I assume Ubuntu also) systems have a on_ac_power\nscript that exits 0 or 1 accordingly. It would be a good thing to point\nthe hook at, or even a good reference when writing your own version of\nthe hook since it also supports /proc/pmu and apm.\n\n-- \nsee shy jo\n"},{"id":"73450","messageId":"E75A6ACE-8EF2-4B12-B591-35C9092FCD9A@silverinsanity.com","threadId":"12924","inReplyTo":"283c63fb960d36a322b45fac97804af18a9e5abe.1206929014.git.vmiklos@frugalware.org","subject":"Re: [PATCH 4/4] templates: add an example pre-auto-gc hook","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2008-03-31T18:30:35Z","receivedAt":"2008-03-31T18:30:35Z","isPatch":true,"sender":{"key":"benji@silverinsanity.com","avatar":"https://gravatar.com/avatar/e06c101dbc25c68114d859b4a9ec7cf8a2c52fd2b0270ef0eac0e2e63ff22311?d=mp&s=160"},"body":"\nOn Mar 31, 2008, at 5:37 AM, Miklos Vajna wrote:\n\n> +# An example hook script to verify if you are on battery.  Called by\n> +# git-gc --auto with no arguments.  The hook should exit with non- \n> zero\n> +# status after issuing an appropriate message if it wants to stop the\n> +# auto repacking.\n> +#\n> +# To enable this hook, make this file executable.\n\nYou probably want to mention that this example hook is Linux-specific.\n\n~~ Brian G.\n"},{"id":"73448","messageId":"47F12E1A.1020602@nrlssc.navy.mil","threadId":"12924","inReplyTo":"20080331173801.GD10018@genesis.frugalware.org","subject":"Re: [PATCH] git gc --auto: defer on battery","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-03-31T18:31:54Z","receivedAt":"2008-03-31T18:31:54Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Miklos Vajna wrote:\n> On Mon, Mar 31, 2008 at 11:24:22AM -0500, Brandon Casey <casey@nrlssc.navy.mil> wrote:\n>> Miklos Vajna wrote:\n>>> This patch modifies git gc --auto so that it will not always repack when\n>>> a user is on battery.\n>>>\n>>> It introduces the new gc.deferonbattery configuration variable,\n>> Shouldn't the config option have 'auto' in the name? Or in some way convey\n>> that this is _only_ about deferring automatic gc'ing?\n> \n> That makes sense. Though this patch isn't OK, see my other patch series\n> in this thread (the pre-auto-gc hook has no config name).\n\nAh, yes I didn't look closely at the revised series.\n\n-brandon\n"},{"id":"73544","messageId":"alpine.LSU.1.00.0804021538220.4008@racer.site","threadId":"12924","inReplyTo":"7vr6drsl47.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] commit: resurrect \"gc --auto\" at the end","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-02T13:40:12Z","receivedAt":"2008-04-02T13:40:12Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nAs the scripted version of git-commit did, we now call gc --auto just \nbefore the post-commit hook.\n\nAny errors of gc --auto should be non-fatal, so we do not catch those; the \nuser should see them anyway.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tJunio wrote:\n\t>\n\t>  * \"git commit\" used to have one [call to 'gc --auto'] at the \n\t>    end in the scripted version, but seems to have lost it in C\n\t>    rewrite.\n\n\tHow about this?\n\n builtin-commit.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 660a345..bec62b2 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -863,6 +863,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \tchar *nl, *p;\n \tunsigned char commit_sha1[20];\n \tstruct ref_lock *ref_lock;\n+\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n \n \tgit_config(git_commit_config);\n \n@@ -987,6 +988,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\t     \"not exceeded, and then \\\"git reset HEAD\\\" to recover.\");\n \n \trerere();\n+\t/* We ignore errors in 'gc --auto', since the user should see them. */\n+\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n \trun_hook(get_index_file(), \"post-commit\", NULL);\n \tif (!quiet)\n \t\tprint_summary(prefix, commit_sha1);\n-- \n1.5.5.rc2.30.gf2056\n"},{"id":"76947","messageId":"alpine.DEB.1.00.0805141607210.30431@racer","threadId":"12924","inReplyTo":"alpine.LSU.1.00.0804021538220.4008@racer.site","subject":"Re: [PATCH] commit: resurrect \"gc --auto\" at the end","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-14T15:07:46Z","receivedAt":"2008-05-14T15:07:46Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 2 Apr 2008, Johannes Schindelin wrote:\n\n> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> \n> As the scripted version of git-commit did, we now call gc --auto just \n> before the post-commit hook.\n> \n> Any errors of gc --auto should be non-fatal, so we do not catch those; the \n> user should see them anyway.\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n> \n> \tJunio wrote:\n> \t>\n> \t>  * \"git commit\" used to have one [call to 'gc --auto'] at the \n> \t>    end in the scripted version, but seems to have lost it in C\n> \t>    rewrite.\n> \n> \tHow about this?\n\nAny news on this?\n\nCiao,\nDscho\n"},{"id":"76967","messageId":"7vlk2coist.fsf@gitster.siamese.dyndns.org","threadId":"12924","inReplyTo":"alpine.DEB.1.00.0805141607210.30431@racer","subject":"Re: [PATCH] commit: resurrect \"gc --auto\" at the end","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-05-14T18:13:38Z","receivedAt":"2008-05-14T18:13:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Wed, 2 Apr 2008, Johannes Schindelin wrote:\n>\n>> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>> \n>> As the scripted version of git-commit did, we now call gc --auto just \n>> before the post-commit hook.\n>> \n>> Any errors of gc --auto should be non-fatal, so we do not catch those; the \n>> user should see them anyway.\n>> \n>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>> ---\n>> \n>> \tJunio wrote:\n>> \t>\n>> \t>  * \"git commit\" used to have one [call to 'gc --auto'] at the \n>> \t>    end in the scripted version, but seems to have lost it in C\n>> \t>    rewrite.\n>> \n>> \tHow about this?\n>\n> Any news on this?\n\nI had an impression that we accepted the hook which made \"gc --auto\" more\nexpensive by forcing it to check the hook (and possibly execute it every\ntime) after vetting am, svn and friends to make sure nobody triggered \"gc\n--auto\" once per every commit, and during that vetting process we noticed\nthat \"git commit\" lost the \"gc --auto\" at the end.\n\nWith this patch, we would again have a command that runs \"gc --auto\" once\nper every commit, wouldn't we?  Interactive use of git-commit is fine with\nit, but if people drive \"git commit\" from their scripts in a loop, they\nwould be hurt.\n\nHaving said that, perhaps the overhead of \"gc --auto\" hook is not such a\nbig deal.  I dunno.\n"},{"id":"76972","messageId":"alpine.DEB.1.00.0805141939470.30431@racer","threadId":"12924","inReplyTo":"7vlk2coist.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] commit: resurrect \"gc --auto\" at the end","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-14T18:40:02Z","receivedAt":"2008-05-14T18:40:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 May 2008, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > On Wed, 2 Apr 2008, Johannes Schindelin wrote:\n> >\n> >> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> >> \n> >> As the scripted version of git-commit did, we now call gc --auto just \n> >> before the post-commit hook.\n> >> \n> >> Any errors of gc --auto should be non-fatal, so we do not catch those; the \n> >> user should see them anyway.\n> >> \n> >> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> >> ---\n> >> \n> >> \tJunio wrote:\n> >> \t>\n> >> \t>  * \"git commit\" used to have one [call to 'gc --auto'] at the \n> >> \t>    end in the scripted version, but seems to have lost it in C\n> >> \t>    rewrite.\n> >> \n> >> \tHow about this?\n> >\n> > Any news on this?\n> \n> I had an impression that we accepted the hook which made \"gc --auto\" \n> more expensive by forcing it to check the hook (and possibly execute it \n> every time) after vetting am, svn and friends to make sure nobody \n> triggered \"gc --auto\" once per every commit, and during that vetting \n> process we noticed that \"git commit\" lost the \"gc --auto\" at the end.\n\nAh yes, completely forgot.  Thanks.\n\nCiao,\nDscho\n"},{"id":"77025","messageId":"200805150844.40451.hs4233@mail.mn-solutions.de","threadId":"12924","inReplyTo":"7vlk2coist.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] commit: resurrect \"gc --auto\" at the end","fromName":"Holger Schurig","fromEmail":"hs4233@mail.mn-solutions.de","sentAt":"2008-05-15T06:44:40Z","receivedAt":"2008-05-15T06:44:40Z","isPatch":true,"sender":{"key":"hs4233@mail.mn-solutions.de","avatar":null},"body":"> With this patch, we would again have a command that runs \"gc\n> --auto\" once per every commit, wouldn't we?\n\nNot sure if we have timing information. E.g. look at the \ntimestamp of some file that \"git gc\" touched and only do this if \nit's old enought. Or look at the previous commit and only \nrun \"gc --auto\" if this is far enought away, e.g. a couple of \nhours.\n"}]}