[PATCH 4/4] templates: add an example pre-auto-gc hook
It disabled git-gc --auto when you are on battery.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
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