git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] Add OS X support to the pre-auto-gc example hook

From
Jonathan del Strother <jon.delstrother@bestbefore.tv>
Date
Sep 29, 2008, 23:36 UTC
Message-ID
<1222731388-833-1-git-send-email-jon.delStrother@bestbefore.tv>
In-Reply-To
<57518fd10809270253s4c07318bjd54c7d86460ce7d7@mail.gmail.com>
Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>
---
Second attempt - this simplifies the test while making it more specific (it will only pack when on AC power, rather than, say, UPS).
 contrib/hooks/pre-auto-gc-battery |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
index 0096f57..b0a8caa 100644
--- a/contrib/hooks/pre-auto-gc-battery
+++ b/contrib/hooks/pre-auto-gc-battery
@@ -1,9 +1,9 @@
 #!/bin/sh
 #
 # An example hook script to verify if you are on battery, in case you
-# are running Linux. 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.
+# are running Linux or OS X. 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.
 #
 # This hook is stored in the contrib/hooks directory. Your distribution
 # may have put this somewhere else. If you want to use this hook, you
@@ -30,6 +30,10 @@ then
 elif grep -q '0x01$' /proc/apm 2>/dev/null
 then
 	exit 0
+elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt |
+	grep -q "Currently drawing from 'AC Power'"
+then
+	exit 0
 fi
 
 echo "Auto packing deferred; not on AC"
-- 
1.6.0.2.308.gd442a.dirty
Previous: Jonathan del StrotherNext: Miklos Vajna
Message 4 of 5 in “Add OS X support to the pre-auto-gc example hook”
  1. Add OS X support to the pre-auto-gc example hookJonathan del Strother, Sep 23, 2008
  2. Miklos VajnaSep 25, 2008
  3. Jonathan del StrotherSep 27, 2008
  4. Add OS X support to the pre-auto-gc example hookJonathan del Strother, Sep 29, 2008
  5. Miklos VajnaSep 30, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.