Thread (2 messages) flat view 2 messages, 2 authors, 2018-02-28

Re: [PATCH] hooks/pre-auto-gc-battery: allow gc to run on non-laptops

From: Junio C Hamano <hidden>
Date: 2018-02-28 18:17:04

Adam Borowski [off-list ref] writes:
Desktops and servers tend to have no power sensor, thus on_ac_power returns
255 ("unknown").

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).
The explanation talks about the exit status 255 being special and
serves to signal "there is no point continuing, and it is OK to
assume we are not on batttery", while the code says that anything
but exit status 1 can be treated as such.  Which is correct?
quoted hunk
Reported by: Xin Li [off-list ref]
Signed-off-by: Adam Borowski <redacted>
---
 contrib/hooks/pre-auto-gc-battery | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
index 6a2cdebdb..7ba78c4df 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help