git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 28, 2018, 18:16 UTC
Message-ID
<xmqqpo4pkmiy.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180228044807.1000-1-kilobyte@angband.pl>
Adam Borowski <kilobyte@angband.pl> writes:
Show 6 quoted lines
> 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?

Show 19 quoted lines
> Reported by: Xin Li <delphij@google.com>
> Signed-off-by: Adam Borowski <kilobyte@angband.pl>
> ---
>  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
Previous: Adam BorowskiNext: Adam Borowski
Message 2 of 6 in “hooks/pre-auto-gc-battery: allow gc to run on non-laptops”
  1. hooks/pre-auto-gc-battery: allow gc to run on non-laptopsAdam Borowski, Feb 28, 2018
  2. Junio C HamanoFeb 28, 2018
  3. Adam BorowskiFeb 28, 2018
  4. Junio C HamanoFeb 28, 2018
  5. hooks/pre-auto-gc-battery: allow gc to run on non-laptopsAdam Borowski, Feb 28, 2018
  6. Junio C HamanoFeb 28, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.