Skip to content

Commit c33912a

Browse files
Jonathan del Strotherspearce
authored andcommitted
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>
1 parent 79fd4cc commit c33912a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

contrib/hooks/pre-auto-gc-battery

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/sh
22
#
33
# 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.
77
#
88
# This hook is stored in the contrib/hooks directory. Your distribution
99
# 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
2828
then
2929
exit 0
3030
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'"
3135
then
3236
exit 0
3337
fi

0 commit comments

Comments
 (0)