From: Jonathan del Strother Date: Mon, 29 Sep 2008 23:36:28 +0000 (+0100) Subject: Add OS X support to the pre-auto-gc example hook X-Git-Tag: v1.6.1-rc1~191 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c33912ae2463b9e486fb016ffa9d21ff8e62984a;p=git.git Add OS X support to the pre-auto-gc example hook Signed-off-by: Jonathan del Strother Acked-by: Miklos Vajna Signed-off-by: Shawn O. Pearce --- 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 @@ -28,6 +28,10 @@ elif grep -q 'on-line' /proc/acpi/ac_adapter/AC/state 2>/dev/null then exit 0 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