Skip to content

Commit 781262c

Browse files
kilobytegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Adam Borowski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38e79b1 commit 781262c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/hooks/pre-auto-gc-battery

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \
1818
# hooks/pre-auto-gc
1919

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)
2121
then
2222
exit 0
2323
elif test "$(cat /sys/class/power_supply/AC/online 2>/dev/null)" = 1

0 commit comments

Comments
 (0)