hooks/pre-auto-gc-battery: allow gc to run on non-laptops
authorAdam Borowski <kilobyte@angband.pl>
Wed, 28 Feb 2018 22:12:04 +0000 (23:12 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Feb 2018 22:24:46 +0000 (14:24 -0800)
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 <delphij@google.com>
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/hooks/pre-auto-gc-battery

index 6a2cdeb..7ba78c4 100755 (executable)
@@ -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