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 <delphij@google.com> Signed-off-by: Adam Borowski <kilobyte@angband.pl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Adam Borowski committed
Feb 28, 2018 at 23:12 UTC
781262c5e7ad4a7813c528803117ed0d2e8c5172
1 file changed
+1
-1
contrib/hooks/pre-auto-gc-battery
+1
-1
@@ -17,7 +17,7 @@
17
# ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \
18
# hooks/pre-auto-gc
19
20
-if test -x /sbin/on_ac_power && /sbin/on_ac_power
20
+if test -x /sbin/on_ac_power && (/sbin/on_ac_power;test $? -ne 1)
21
then
22
exit 0
23
elif test "$(cat /sys/class/power_supply/AC/online 2>/dev/null)" = 1