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>
Jonathan del Strother committed
Sep 30, 2008 at 00:36 UTC
c33912ae2463b9e486fb016ffa9d21ff8e62984a
1 file changed
+7
-3
contrib/hooks/pre-auto-gc-battery
+7
-3
@@ -1,9 +1,9 @@
1
#!/bin/sh
2
#
3
# An example hook script to verify if you are on battery, in case you
4
-# are running Linux. Called by git-gc --auto with no arguments. The hook
5
-# should exit with non-zero status after issuing an appropriate message
6
-# if it wants to stop the auto repacking.
4
+# are running Linux or OS X. Called by git-gc --auto with no arguments.
5
+# The hook should exit with non-zero status after issuing an appropriate
6
+# message if it wants to stop the auto repacking.
7
#
8
# This hook is stored in the contrib/hooks directory. Your distribution
9
# may have put this somewhere else. If you want to use this hook, you
@@ -28,6 +28,10 @@ elif grep -q 'on-line' /proc/acpi/ac_adapter/AC/state 2>/dev/null
28
then
29
exit 0
30
elif grep -q '0x01$' /proc/apm 2>/dev/null
31
+then
32
+ exit 0
33
+elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt |
34
+ grep -q "Currently drawing from 'AC Power'"
35
then
36
exit 0
37
fi