Re: [PATCH v2] hooks/pre-auto-gc-battery: allow gc to run on non-laptops
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 28, 2018, 22:24 UTC
- Message-ID
- <xmqq4lm0kb1b.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180228221204.27356-1-kilobyte@angband.pl>
Adam Borowski <kilobyte@angband.pl> writes:
Show 12 quoted lines
> 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>
> ---
> v2: improved commit messageThat makes the patch and the log consistent so that people who know the area can reason about it ;-)
Will queue. Thanks.
Show 16 quoted lines
> 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