* Re: [PATCH] git gc --auto: defer on battery
2008-03-30 23:46 ` Linus Torvalds
@ 2008-03-31 0:00 ` Björn Steinbrink
2008-03-31 2:06 ` Junio C Hamano
` (6 subsequent siblings)
7 siblings, 0 replies; 27+ messages in thread
From: Björn Steinbrink @ 2008-03-31 0:00 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Miklos Vajna, Junio C Hamano, git
On 2008.03.30 16:46:51 -0700, Linus Torvalds wrote:
>
>
> On Mon, 31 Mar 2008, Bj?rn Steinbrink wrote:
> >
> > The /proc stuff is already deprecated IIRC, the new file to check on
> > Linux is /sys/class/power_supply/AC/online.
>
> I would *seriously* suggest making this soem kind of generic callback and
> not Linux-specific.
I didn't meant to make that Linux-specific, I just wanted to mention
that the /proc stuff might break rather "soon", and that the code should
also check the the sysfs stuff.
> How about making it more akin to a pre-auto-gc "hook" - run a script
> instead of hardcoding something like this!
Sounds nice.
Björn
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] git gc --auto: defer on battery
2008-03-30 23:46 ` Linus Torvalds
2008-03-31 0:00 ` Björn Steinbrink
@ 2008-03-31 2:06 ` Junio C Hamano
2008-03-31 15:02 ` Linus Torvalds
2008-04-02 13:40 ` [PATCH] commit: resurrect "gc --auto" at the end Johannes Schindelin
2008-03-31 9:35 ` [PATCH 0/4] add pre-auto-gc hook for git-gc --auto Miklos Vajna
` (5 subsequent siblings)
7 siblings, 2 replies; 27+ messages in thread
From: Junio C Hamano @ 2008-03-31 2:06 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Bj?rn Steinbrink, Miklos Vajna, git
Linus Torvalds <torvalds@linux-foundation.org> writes:
> On Mon, 31 Mar 2008, Bj?rn Steinbrink wrote:
>>
>> The /proc stuff is already deprecated IIRC, the new file to check on
>> Linux is /sys/class/power_supply/AC/online.
>
> I would *seriously* suggest making this soem kind of generic callback and
> not Linux-specific.
>
> How about making it more akin to a pre-auto-gc "hook" - run a script
> instead of hardcoding something like this!
That would be a sensible approach.
We also would need to make sure that Porcelain that call "gc --auto" does
not have an assumption that auto is ultra-cheap, however, as we are
talking about potentially two fork-exec in the usual "noop" case with such
a change, but we need to do that regardless.
* git-svn has "every 1000 commits and one at the end" which should be
Ok.
* git-cvsimport does "repack -a -d" every 1k commits and once more at the
end if there are many remaining loose objects.
* "git-rebase -i" does one at the end, which should be Ok.
* "git commit" used to have one at the end in the scripted version, but
seems to have lost it in C rewrite.
So I think we are Ok with an additional hook.
By the way, Linus, is your MUA UTF-8 challenged? I see Björn's name on
the To: header mangled.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] git gc --auto: defer on battery
2008-03-31 2:06 ` Junio C Hamano
@ 2008-03-31 15:02 ` Linus Torvalds
2008-03-31 16:43 ` Björn Steinbrink
2008-04-02 13:40 ` [PATCH] commit: resurrect "gc --auto" at the end Johannes Schindelin
1 sibling, 1 reply; 27+ messages in thread
From: Linus Torvalds @ 2008-03-31 15:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Bj?rn Steinbrink, Miklos Vajna, git
On Sun, 30 Mar 2008, Junio C Hamano wrote:
>
> By the way, Linus, is your MUA UTF-8 challenged? I see Björn's name on
> the To: header mangled.
My MUA is not utf-8 challenged per se, but it doesn't seem to like Björn's
headers.
For example, I see "しらいしななこ <nanako3@bluebottle.com>" perfectly
correctly (Content-Type: text/plain; charset=UTF-8), but Björn's emails
tend to be (Content-Type: text/plain; charset=iso-8859-1) but then he has
his email address in utf-8, and that seems to be what makes my MUA
unhappy about it.
Linus
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] git gc --auto: defer on battery
2008-03-31 15:02 ` Linus Torvalds
@ 2008-03-31 16:43 ` Björn Steinbrink
2008-03-31 17:00 ` fetchmail (Re: [PATCH] git gc --auto: defer on battery) Linus Torvalds
0 siblings, 1 reply; 27+ messages in thread
From: Björn Steinbrink @ 2008-03-31 16:43 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Junio C Hamano, Miklos Vajna, git
On 2008.03.31 08:02:51 -0700, Linus Torvalds wrote:
>
>
> On Sun, 30 Mar 2008, Junio C Hamano wrote:
> >
> > By the way, Linus, is your MUA UTF-8 challenged? I see Björn's name on
> > the To: header mangled.
>
> My MUA is not utf-8 challenged per se, but it doesn't seem to like Björn's
> headers.
>
> For example, I see "しらいしななこ <nanako3@bluebottle.com>" perfectly
> correctly (Content-Type: text/plain; charset=UTF-8), but Björn's emails
> tend to be (Content-Type: text/plain; charset=iso-8859-1) but then he has
> his email address in utf-8, and that seems to be what makes my MUA
> unhappy about it.
Hm, that's weird. My header shows my name as iso-8859-1, same as the
body. I checked the copy that I got from the list to eliminate any weird
local-copy effects.
From: =?iso-8859-1?Q?Bj=F6rn?= Steinbrink <B.Steinbrink@gmx.de>
So maybe your MUA is iso-8859-1 challenged instead? I'll send this one
out as UTF-8.
Björn
^ permalink raw reply [flat|nested] 27+ messages in thread
* fetchmail (Re: [PATCH] git gc --auto: defer on battery)
2008-03-31 16:43 ` Björn Steinbrink
@ 2008-03-31 17:00 ` Linus Torvalds
0 siblings, 0 replies; 27+ messages in thread
From: Linus Torvalds @ 2008-03-31 17:00 UTC (permalink / raw)
To: Bj?rn Steinbrink; +Cc: Junio C Hamano, Miklos Vajna, git
On Mon, 31 Mar 2008, Bj?rn Steinbrink wrote:
>
> Hm, that's weird. My header shows my name as iso-8859-1, same as the
> body. I checked the copy that I got from the list to eliminate any weird
> local-copy effects.
>
> From: =?iso-8859-1?Q?Bj=F6rn?= Steinbrink <B.Steinbrink@gmx.de>
>
> So maybe your MUA is iso-8859-1 challenged instead? I'll send this one
> out as UTF-8.
Ahhah! That's it. Not my MUA, but I'm using fetchmail, and I have copied
my .fetchmailrc file around for years. As a result, it has 'mimedecode'
set, because pine used to be really bad at this and obviously all my
original BK (and later git) email scripts didn't do mime decoding either.
So what is probably happening is that my fetchmail setup dropped the
charset information for the header (this is documented by fetchmail, so
it's not a bug, it's just part of the rules) and just turned it into the
raw byte sequence.
I've turned off mimedecode, can you send another email to me (in private)
to see if not doing that just fixes things?
Linus
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH] commit: resurrect "gc --auto" at the end
2008-03-31 2:06 ` Junio C Hamano
2008-03-31 15:02 ` Linus Torvalds
@ 2008-04-02 13:40 ` Johannes Schindelin
2008-05-14 15:07 ` Johannes Schindelin
1 sibling, 1 reply; 27+ messages in thread
From: Johannes Schindelin @ 2008-04-02 13:40 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
From: Johannes Schindelin <johannes.schindelin@gmx.de>
As the scripted version of git-commit did, we now call gc --auto just
before the post-commit hook.
Any errors of gc --auto should be non-fatal, so we do not catch those; the
user should see them anyway.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Junio wrote:
>
> * "git commit" used to have one [call to 'gc --auto'] at the
> end in the scripted version, but seems to have lost it in C
> rewrite.
How about this?
builtin-commit.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 660a345..bec62b2 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -863,6 +863,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
char *nl, *p;
unsigned char commit_sha1[20];
struct ref_lock *ref_lock;
+ const char *argv_gc_auto[] = { "gc", "--auto", NULL };
git_config(git_commit_config);
@@ -987,6 +988,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
"not exceeded, and then \"git reset HEAD\" to recover.");
rerere();
+ /* We ignore errors in 'gc --auto', since the user should see them. */
+ run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
run_hook(get_index_file(), "post-commit", NULL);
if (!quiet)
print_summary(prefix, commit_sha1);
--
1.5.5.rc2.30.gf2056
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH] commit: resurrect "gc --auto" at the end
2008-04-02 13:40 ` [PATCH] commit: resurrect "gc --auto" at the end Johannes Schindelin
@ 2008-05-14 15:07 ` Johannes Schindelin
2008-05-14 18:13 ` Junio C Hamano
0 siblings, 1 reply; 27+ messages in thread
From: Johannes Schindelin @ 2008-05-14 15:07 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hi,
On Wed, 2 Apr 2008, Johannes Schindelin wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> As the scripted version of git-commit did, we now call gc --auto just
> before the post-commit hook.
>
> Any errors of gc --auto should be non-fatal, so we do not catch those; the
> user should see them anyway.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>
> Junio wrote:
> >
> > * "git commit" used to have one [call to 'gc --auto'] at the
> > end in the scripted version, but seems to have lost it in C
> > rewrite.
>
> How about this?
Any news on this?
Ciao,
Dscho
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] commit: resurrect "gc --auto" at the end
2008-05-14 15:07 ` Johannes Schindelin
@ 2008-05-14 18:13 ` Junio C Hamano
2008-05-14 18:40 ` Johannes Schindelin
2008-05-15 6:44 ` Holger Schurig
0 siblings, 2 replies; 27+ messages in thread
From: Junio C Hamano @ 2008-05-14 18:13 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> On Wed, 2 Apr 2008, Johannes Schindelin wrote:
>
>> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>>
>> As the scripted version of git-commit did, we now call gc --auto just
>> before the post-commit hook.
>>
>> Any errors of gc --auto should be non-fatal, so we do not catch those; the
>> user should see them anyway.
>>
>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>> ---
>>
>> Junio wrote:
>> >
>> > * "git commit" used to have one [call to 'gc --auto'] at the
>> > end in the scripted version, but seems to have lost it in C
>> > rewrite.
>>
>> How about this?
>
> Any news on this?
I had an impression that we accepted the hook which made "gc --auto" more
expensive by forcing it to check the hook (and possibly execute it every
time) after vetting am, svn and friends to make sure nobody triggered "gc
--auto" once per every commit, and during that vetting process we noticed
that "git commit" lost the "gc --auto" at the end.
With this patch, we would again have a command that runs "gc --auto" once
per every commit, wouldn't we? Interactive use of git-commit is fine with
it, but if people drive "git commit" from their scripts in a loop, they
would be hurt.
Having said that, perhaps the overhead of "gc --auto" hook is not such a
big deal. I dunno.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] commit: resurrect "gc --auto" at the end
2008-05-14 18:13 ` Junio C Hamano
@ 2008-05-14 18:40 ` Johannes Schindelin
2008-05-15 6:44 ` Holger Schurig
1 sibling, 0 replies; 27+ messages in thread
From: Johannes Schindelin @ 2008-05-14 18:40 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hi,
On Wed, 14 May 2008, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > On Wed, 2 Apr 2008, Johannes Schindelin wrote:
> >
> >> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >>
> >> As the scripted version of git-commit did, we now call gc --auto just
> >> before the post-commit hook.
> >>
> >> Any errors of gc --auto should be non-fatal, so we do not catch those; the
> >> user should see them anyway.
> >>
> >> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> >> ---
> >>
> >> Junio wrote:
> >> >
> >> > * "git commit" used to have one [call to 'gc --auto'] at the
> >> > end in the scripted version, but seems to have lost it in C
> >> > rewrite.
> >>
> >> How about this?
> >
> > Any news on this?
>
> I had an impression that we accepted the hook which made "gc --auto"
> more expensive by forcing it to check the hook (and possibly execute it
> every time) after vetting am, svn and friends to make sure nobody
> triggered "gc --auto" once per every commit, and during that vetting
> process we noticed that "git commit" lost the "gc --auto" at the end.
Ah yes, completely forgot. Thanks.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] commit: resurrect "gc --auto" at the end
2008-05-14 18:13 ` Junio C Hamano
2008-05-14 18:40 ` Johannes Schindelin
@ 2008-05-15 6:44 ` Holger Schurig
1 sibling, 0 replies; 27+ messages in thread
From: Holger Schurig @ 2008-05-15 6:44 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Johannes Schindelin
> With this patch, we would again have a command that runs "gc
> --auto" once per every commit, wouldn't we?
Not sure if we have timing information. E.g. look at the
timestamp of some file that "git gc" touched and only do this if
it's old enought. Or look at the previous commit and only
run "gc --auto" if this is far enought away, e.g. a couple of
hours.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 0/4] add pre-auto-gc hook for git-gc --auto
2008-03-30 23:46 ` Linus Torvalds
2008-03-31 0:00 ` Björn Steinbrink
2008-03-31 2:06 ` Junio C Hamano
@ 2008-03-31 9:35 ` Miklos Vajna
2008-03-31 9:35 ` [PATCH 1/4] git-gc --auto: add pre-auto-gc hook Miklos Vajna
` (4 subsequent siblings)
7 siblings, 0 replies; 27+ messages in thread
From: Miklos Vajna @ 2008-03-31 9:35 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Bj?rn Steinbrink, Junio C Hamano, git
On Sun, Mar 30, 2008 at 04:46:51PM -0700, Linus Torvalds <torvalds@linux-foundation.org> wrote:
> How about making it more akin to a pre-auto-gc "hook" - run a script
> instead of hardcoding something like this!
Something like this?
Miklos Vajna (4):
git-gc --auto: add pre-auto-gc hook
git-gc: add a --no-verify option to bypass the pre-auto-gc hook
Documentation/hooks: add pre-auto-gc hook
templates: add an example pre-auto-gc hook
Documentation/git-gc.txt | 4 ++++
Documentation/hooks.txt | 10 ++++++++++
builtin-gc.c | 24 ++++++++++++++++++++++++
templates/hooks--pre-auto-gc | 29 +++++++++++++++++++++++++++++
4 files changed, 67 insertions(+), 0 deletions(-)
create mode 100644 templates/hooks--pre-auto-gc
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 1/4] git-gc --auto: add pre-auto-gc hook
2008-03-30 23:46 ` Linus Torvalds
` (2 preceding siblings ...)
2008-03-31 9:35 ` [PATCH 0/4] add pre-auto-gc hook for git-gc --auto Miklos Vajna
@ 2008-03-31 9:35 ` Miklos Vajna
2008-03-31 9:36 ` [PATCH 2/4] git-gc: add a --no-verify option to bypass the " Miklos Vajna
` (3 subsequent siblings)
7 siblings, 0 replies; 27+ messages in thread
From: Miklos Vajna @ 2008-03-31 9:35 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Bj?rn Steinbrink, Junio C Hamano, git
If such a hook is available and exits with a non-zero status, then
git-gc --auto won't run.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
builtin-gc.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/builtin-gc.c b/builtin-gc.c
index 8cef36f..acd63be 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -157,6 +157,25 @@ static int too_many_packs(void)
return gc_auto_pack_limit <= cnt;
}
+static int run_hook()
+{
+ const char *argv[2];
+ struct child_process hook;
+
+ argv[0] = git_path("hooks/pre-auto-gc");
+ argv[1] = NULL;
+
+ if (access(argv[0], X_OK) < 0)
+ return 0;
+
+ memset(&hook, 0, sizeof(hook));
+ hook.argv = argv;
+ hook.no_stdin = 1;
+ hook.stdout_to_stderr = 1;
+
+ return run_command(&hook);
+}
+
static int need_to_gc(void)
{
/*
@@ -176,6 +195,9 @@ static int need_to_gc(void)
append_option(argv_repack, "-A", MAX_ADD);
else if (!too_many_loose_objects())
return 0;
+
+ if (run_hook())
+ return 0;
return 1;
}
--
1.5.5.rc2.4.g283c6
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 2/4] git-gc: add a --no-verify option to bypass the pre-auto-gc hook
2008-03-30 23:46 ` Linus Torvalds
` (3 preceding siblings ...)
2008-03-31 9:35 ` [PATCH 1/4] git-gc --auto: add pre-auto-gc hook Miklos Vajna
@ 2008-03-31 9:36 ` Miklos Vajna
2008-03-31 9:36 ` [PATCH 3/4] Documentation/hooks: add " Miklos Vajna
` (2 subsequent siblings)
7 siblings, 0 replies; 27+ messages in thread
From: Miklos Vajna @ 2008-03-31 9:36 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Bj?rn Steinbrink, Junio C Hamano, git
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
Documentation/git-gc.txt | 4 ++++
builtin-gc.c | 4 +++-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
index d424a4e..396da5c 100644
--- a/Documentation/git-gc.txt
+++ b/Documentation/git-gc.txt
@@ -62,6 +62,10 @@ automatic consolidation of packs.
--quiet::
Suppress all progress reports.
+--no-verify::
+ This option bypasses the pre-auto-gc hook.
+ See also link:hooks.html[hooks].
+
Configuration
-------------
diff --git a/builtin-gc.c b/builtin-gc.c
index acd63be..1eca6b2 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -27,6 +27,7 @@ static int aggressive_window = -1;
static int gc_auto_threshold = 6700;
static int gc_auto_pack_limit = 50;
static char *prune_expire = "2.weeks.ago";
+static int no_verify;
#define MAX_ADD 10
static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
@@ -196,7 +197,7 @@ static int need_to_gc(void)
else if (!too_many_loose_objects())
return 0;
- if (run_hook())
+ if (!no_verify && run_hook())
return 0;
return 1;
}
@@ -214,6 +215,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
OPT_BOOLEAN(0, "aggressive", &aggressive, "be more thorough (increased runtime)"),
OPT_BOOLEAN(0, "auto", &auto_gc, "enable auto-gc mode"),
OPT_BOOLEAN('q', "quiet", &quiet, "suppress progress reports"),
+ OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-auto-gc hook"),
OPT_END()
};
--
1.5.5.rc2.4.g283c6
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 3/4] Documentation/hooks: add pre-auto-gc hook
2008-03-30 23:46 ` Linus Torvalds
` (4 preceding siblings ...)
2008-03-31 9:36 ` [PATCH 2/4] git-gc: add a --no-verify option to bypass the " Miklos Vajna
@ 2008-03-31 9:36 ` Miklos Vajna
2008-03-31 9:37 ` [PATCH 4/4] templates: add an example " Miklos Vajna
2008-03-31 18:08 ` [PATCH] git gc --auto: defer on battery Joey Hess
7 siblings, 0 replies; 27+ messages in thread
From: Miklos Vajna @ 2008-03-31 9:36 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Bj?rn Steinbrink, Junio C Hamano, git
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
Documentation/hooks.txt | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/Documentation/hooks.txt b/Documentation/hooks.txt
index 76b8d77..04ec352 100644
--- a/Documentation/hooks.txt
+++ b/Documentation/hooks.txt
@@ -276,3 +276,13 @@ probably enable this hook.
Both standard output and standard error output are forwarded to
`git-send-pack` on the other end, so you can simply `echo` messages
for the user.
+
+pre-auto-gc
+-----------
+
+This hook is invoked by `git-gc --auto`, and can be bypassed with
+`\--no-verify` option. It takes no parameter, and exiting with non-zero
+status from this script causes the `git-gc --auto` to abort.
+
+The default 'pre-auto-gc' hook, when enabled, defers auto repacking when
+you are on battery.
--
1.5.5.rc2.4.g283c6
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 4/4] templates: add an example pre-auto-gc hook
2008-03-30 23:46 ` Linus Torvalds
` (5 preceding siblings ...)
2008-03-31 9:36 ` [PATCH 3/4] Documentation/hooks: add " Miklos Vajna
@ 2008-03-31 9:37 ` Miklos Vajna
2008-03-31 18:30 ` Brian Gernhardt
2008-03-31 18:08 ` [PATCH] git gc --auto: defer on battery Joey Hess
7 siblings, 1 reply; 27+ messages in thread
From: Miklos Vajna @ 2008-03-31 9:37 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Bj?rn Steinbrink, Junio C Hamano, git
It disabled git-gc --auto when you are on battery.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
templates/hooks--pre-auto-gc | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
create mode 100644 templates/hooks--pre-auto-gc
diff --git a/templates/hooks--pre-auto-gc b/templates/hooks--pre-auto-gc
new file mode 100644
index 0000000..40c4759
--- /dev/null
+++ b/templates/hooks--pre-auto-gc
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# An example hook script to verify if you are on battery. Called by
+# git-gc --auto with no arguments. The hook should exit with non-zero
+# status after issuing an appropriate message if it wants to stop the
+# auto repacking.
+#
+# To enable this hook, make this file executable.
+
+defer=0
+
+if [ -e /sys/class/power_supply/AC/online ]; then
+ if [ "`cat /sys/class/power_supply/AC/online`" = 0 ]; then
+ defer=1
+ fi
+elif [ -e /proc/acpi/ac_adapter/AC/state ]; then
+ if grep -q 'off-line' /proc/acpi/ac_adapter/AC/state; then
+ defer=1
+ fi
+elif [ -e /proc/apm ]; then
+ if grep -q '0$' /proc/apm; then
+ defer=1
+ fi
+fi
+
+if [ "$defer" = 1 ]; then
+ echo "Auto packing deferred; on battery"
+ exit 1
+fi
--
1.5.5.rc2.4.g283c6
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 4/4] templates: add an example pre-auto-gc hook
2008-03-31 9:37 ` [PATCH 4/4] templates: add an example " Miklos Vajna
@ 2008-03-31 18:30 ` Brian Gernhardt
0 siblings, 0 replies; 27+ messages in thread
From: Brian Gernhardt @ 2008-03-31 18:30 UTC (permalink / raw)
To: Miklos Vajna; +Cc: Linus Torvalds, Bj?rn Steinbrink, Junio C Hamano, git
On Mar 31, 2008, at 5:37 AM, Miklos Vajna wrote:
> +# An example hook script to verify if you are on battery. Called by
> +# git-gc --auto with no arguments. The hook should exit with non-
> zero
> +# status after issuing an appropriate message if it wants to stop the
> +# auto repacking.
> +#
> +# To enable this hook, make this file executable.
You probably want to mention that this example hook is Linux-specific.
~~ Brian G.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] git gc --auto: defer on battery
2008-03-30 23:46 ` Linus Torvalds
` (6 preceding siblings ...)
2008-03-31 9:37 ` [PATCH 4/4] templates: add an example " Miklos Vajna
@ 2008-03-31 18:08 ` Joey Hess
7 siblings, 0 replies; 27+ messages in thread
From: Joey Hess @ 2008-03-31 18:08 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 534 bytes --]
Linus Torvalds wrote:
> I would *seriously* suggest making this soem kind of generic callback and
> not Linux-specific.
>
> How about making it more akin to a pre-auto-gc "hook" - run a script
> instead of hardcoding something like this!
FWIW, Debian (and I assume Ubuntu also) systems have a on_ac_power
script that exits 0 or 1 accordingly. It would be a good thing to point
the hook at, or even a good reference when writing your own version of
the hook since it also supports /proc/pmu and apm.
--
see shy jo
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread