aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJonathan del Strother <jon.delStrother@bestbefore.tv>2008-09-30 00:36:28 +0100
committerShawn O. Pearce <spearce@spearce.org>2008-09-30 12:27:20 -0700
commitc33912ae2463b9e486fb016ffa9d21ff8e62984a (patch)
tree29ed60c553de99959497996130c8901ff851f55b /contrib
parent79fd4cc749826dd78c6ab3cd225bdb5c92db2de8 (diff)
downloadgit-c33912ae2463b9e486fb016ffa9d21ff8e62984a.tar.gz
git-c33912ae2463b9e486fb016ffa9d21ff8e62984a.tar.xz
Add OS X support to the pre-auto-gc example hook
Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv> Acked-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/hooks/pre-auto-gc-battery10
1 files changed, 7 insertions, 3 deletions
diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
index 0096f57b7..b0a8caae9 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"