From 781262c5e7ad4a7813c528803117ed0d2e8c5172 Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Wed, 28 Feb 2018 23:12:04 +0100 Subject: hooks/pre-auto-gc-battery: allow gc to run on non-laptops Desktops and servers tend to have no power sensor, thus on_ac_power returns 255 ("unknown"). Thus, let's take any answer other than 1 ("battery") as no contraindication to run gc. If that tool returns "unknown", there's no point in querying other sources as it already queried them, and is smarter than us (can handle multiple adapters). Reported by: Xin Li Signed-off-by: Adam Borowski Signed-off-by: Junio C Hamano diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery index 6a2cdeb..7ba78c4 100755 --- a/contrib/hooks/pre-auto-gc-battery +++ b/contrib/hooks/pre-auto-gc-battery @@ -17,7 +17,7 @@ # ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \ # hooks/pre-auto-gc -if test -x /sbin/on_ac_power && /sbin/on_ac_power +if test -x /sbin/on_ac_power && (/sbin/on_ac_power;test $? -ne 1) then exit 0 elif test "$(cat /sys/class/power_supply/AC/online 2>/dev/null)" = 1 -- cgit v0.10.2-6-g49f6