From: Miklos Vajna Date: Mon, 31 Mar 2008 09:37:22 GMT Subject: [PATCH 4/4] templates: add an example pre-auto-gc hook Message-ID: <283c63fb960d36a322b45fac97804af18a9e5abe.1206929014.git.vmiklos@frugalware.org> In-Reply-To: It disabled git-gc --auto when you are on battery. Signed-off-by: Miklos Vajna --- templates/hooks--pre-auto-gc | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) create mode 100644 templates/hooks--pre-auto-gc diff --git a/templates/hooks--pre-auto-gc b/templates/hooks--pre-auto-gc new file mode 100644 index 0000000..40c4759 --- /dev/null +++ b/templates/hooks--pre-auto-gc @@ -0,0 +1,29 @@ +#!/bin/sh +# +# An example hook script to verify if you are on battery. 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. +# +# To enable this hook, make this file executable. + +defer=0 + +if [ -e /sys/class/power_supply/AC/online ]; then + if [ "`cat /sys/class/power_supply/AC/online`" = 0 ]; then + defer=1 + fi +elif [ -e /proc/acpi/ac_adapter/AC/state ]; then + if grep -q 'off-line' /proc/acpi/ac_adapter/AC/state; then + defer=1 + fi +elif [ -e /proc/apm ]; then + if grep -q '0$' /proc/apm; then + defer=1 + fi +fi + +if [ "$defer" = 1 ]; then + echo "Auto packing deferred; on battery" + exit 1 +fi -- 1.5.5.rc2.4.g283c6