{"thread":{"id":"15644","subject":"[PATCH] Add OS X support to the pre-auto-gc example hook","startedAt":"2008-09-23T22:43:23Z","lastAt":"2008-09-30T15:00:36Z","messageCount":5,"participants":["Jonathan del Strother","Miklos Vajna"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91439","messageId":"1222209803-4401-1-git-send-email-jon.delStrother@bestbefore.tv","threadId":"15644","inReplyTo":null,"subject":"[PATCH] Add OS X support to the pre-auto-gc example hook","fromName":"Jonathan del Strother","fromEmail":"jon.delstrother@bestbefore.tv","sentAt":"2008-09-23T22:43:23Z","receivedAt":"2008-09-23T22:43:23Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n---\n\nDarwin / OS X has a pmset tool for getting power management information.  How about adding OS X support to the auto-gc hook?\nShell scripting isn't my fortÃ©, suggestions for improvements would be welcome.\n\n contrib/hooks/pre-auto-gc-battery |    9 ++++++---\n 1 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery\nindex 0096f57..0b7bcde 100644\n--- a/contrib/hooks/pre-auto-gc-battery\n+++ b/contrib/hooks/pre-auto-gc-battery\n@@ -1,9 +1,9 @@\n #!/bin/sh\n #\n # An example hook script to verify if you are on battery, in case you\n-# are running Linux. Called by git-gc --auto with no arguments. The hook\n-# should exit with non-zero status after issuing an appropriate message\n-# if it wants to stop the auto repacking.\n+# are running Linux or OS X. Called by git-gc --auto with no arguments.\n+# The hook should exit with non-zero status after issuing an appropriate\n+# message if it wants to stop the auto repacking.\n #\n # This hook is stored in the contrib/hooks directory. Your distribution\n # may have put this somewhere else. If you want to use this hook, you\n@@ -30,6 +30,9 @@ then\n elif grep -q '0x01$' /proc/apm 2>/dev/null\n then\n \texit 0\n+elif test -x /usr/bin/pmset && (! /usr/bin/pmset -g batt | grep -q 'Battery Power' )\n+then\n+\texit 0\n fi\n \n echo \"Auto packing deferred; not on AC\"\n-- \n1.6.0.2.308.gd442a.dirty\n"},{"id":"91647","messageId":"20080925232008.GO23137@genesis.frugalware.org","threadId":"15644","inReplyTo":"1222209803-4401-1-git-send-email-jon.delStrother@bestbefore.tv","subject":"Re: [PATCH] Add OS X support to the pre-auto-gc example hook","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-09-25T23:20:08Z","receivedAt":"2008-09-25T23:20:08Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Tue, Sep 23, 2008 at 11:43:23PM +0100, Jonathan del Strother <jon.delStrother@bestbefore.tv> wrote:\n> Shell scripting isn't my fortĂŠ, suggestions for improvements would be\n> welcome.\n> \n> +elif test -x /usr/bin/pmset && (! /usr/bin/pmset -g batt | grep -q 'Battery Power' )\n\nWhat about\n\n+elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt | grep -q 'AC Power'\n\n?\n"},{"id":"91738","messageId":"57518fd10809270253s4c07318bjd54c7d86460ce7d7@mail.gmail.com","threadId":"15644","inReplyTo":"20080925232008.GO23137@genesis.frugalware.org","subject":"Re: [PATCH] Add OS X support to the pre-auto-gc example hook","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-09-27T09:53:31Z","receivedAt":"2008-09-27T09:53:31Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"On Fri, Sep 26, 2008 at 12:20 AM, Miklos Vajna <vmiklos@frugalware.org> wrote:\n> On Tue, Sep 23, 2008 at 11:43:23PM +0100, Jonathan del Strother <jon.delStrother@bestbefore.tv> wrote:\n>> Shell scripting isn't my fortĂŠ, suggestions for improvements would be\n>> welcome.\n>>\n>> +elif test -x /usr/bin/pmset && (! /usr/bin/pmset -g batt | grep -q 'Battery Power' )\n>\n> What about\n>\n> +elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt | grep -q 'AC Power'\n>\n> ?\nI was trying to handle pmset reporting anything other than Battery\nPower (currently it reports either Battery, UPS, or AC), but thinking\nabout it, if you're on UPS, you probably don't want git gc eating into\nyour remaining power...\nI'll post an updated version on Monday.\n"},{"id":"91887","messageId":"1222731388-833-1-git-send-email-jon.delStrother@bestbefore.tv","threadId":"15644","inReplyTo":"57518fd10809270253s4c07318bjd54c7d86460ce7d7@mail.gmail.com","subject":"[PATCH v2] Add OS X support to the pre-auto-gc example hook","fromName":"Jonathan del Strother","fromEmail":"jon.delstrother@bestbefore.tv","sentAt":"2008-09-29T23:36:28Z","receivedAt":"2008-09-29T23:36:28Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n---\nSecond attempt - this simplifies the test while making it more specific (it will only pack when on AC power, rather than, say, UPS).\n\n contrib/hooks/pre-auto-gc-battery |   10 +++++++---\n 1 files changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery\nindex 0096f57..b0a8caa 100644\n--- a/contrib/hooks/pre-auto-gc-battery\n+++ b/contrib/hooks/pre-auto-gc-battery\n@@ -1,9 +1,9 @@\n #!/bin/sh\n #\n # An example hook script to verify if you are on battery, in case you\n-# are running Linux. Called by git-gc --auto with no arguments. The hook\n-# should exit with non-zero status after issuing an appropriate message\n-# if it wants to stop the auto repacking.\n+# are running Linux or OS X. Called by git-gc --auto with no arguments.\n+# The hook should exit with non-zero status after issuing an appropriate\n+# message if it wants to stop the auto repacking.\n #\n # This hook is stored in the contrib/hooks directory. Your distribution\n # may have put this somewhere else. If you want to use this hook, you\n@@ -30,6 +30,10 @@ then\n elif grep -q '0x01$' /proc/apm 2>/dev/null\n then\n \texit 0\n+elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt |\n+\tgrep -q \"Currently drawing from 'AC Power'\"\n+then\n+\texit 0\n fi\n \n echo \"Auto packing deferred; not on AC\"\n-- \n1.6.0.2.308.gd442a.dirty\n"},{"id":"91952","messageId":"20080930150036.GB23137@genesis.frugalware.org","threadId":"15644","inReplyTo":"1222731388-833-1-git-send-email-jon.delStrother@bestbefore.tv","subject":"Re: [PATCH v2] Add OS X support to the pre-auto-gc example hook","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-09-30T15:00:36Z","receivedAt":"2008-09-30T15:00:36Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Tue, Sep 30, 2008 at 12:36:28AM +0100, Jonathan del Strother <jon.delStrother@bestbefore.tv> wrote:\n> Second attempt - this simplifies the test while making it more\n> specific (it will only pack when on AC power, rather than, say, UPS).\n\nAcked-by: Miklos Vajna <vmiklos@frugalware.org>\n\nThanks.\n"}]}