All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org,  linux-kernel@vger.kernel.org,
	 Jeff King <peff@peff.net>,
	 Sean Christopherson <seanjc@google.com>,
	 Josh Poimboeuf <jpoimboe@kernel.org>
Subject: Re: [PATCH v4] setlocalversion: work around "git describe" performance
Date: Sat, 23 Nov 2024 23:12:39 +0100	[thread overview]
Message-ID: <87iksdk3ag.fsf@prevas.dk> (raw)
In-Reply-To: <CAK7LNAS6aU4L+4JyDXzncMVsY+6XRYTD=RkhcXSUXTRh_WxWWw@mail.gmail.com> (Masahiro Yamada's message of "Sat, 23 Nov 2024 17:06:50 +0900")

On Sat, Nov 23 2024, Masahiro Yamada <masahiroy@kernel.org> wrote:

> On Sat, Nov 23, 2024 at 12:01 AM Rasmus Villemoes
> <linux@rasmusvillemoes.dk> wrote:

>> v4:
>>
>> - Switch the logic to make use of the return values from try_tag,
>>   instead of asking whether $count has been set.
>
>
> No, please do not do this.
>
> As I replied in v3, my plan is to set -e, because otherwise
> the shell script is fragile.
>
> With this version, -e will not work in try_tag()
> because it is used in the if condition.

I'm confused. Previously you said that "either style is fine with
me". Now you've invented some necessity to add "set -e", which of course
yes, is then suppressed inside try_tag. But there is not a single
statement within that that would cause "set -e" to exit anyway: The only
one that is not a simple assignment or is itself a test is the "set --
$()", and git rev-list failing there does not cause set -e to trigger.

Aside from that, I'm skeptical to introducing set -e anyway, it's simply
too hard to reason about what it will actually
do. http://mywiki.wooledge.org/BashFAQ/105 . But you're the maintainer.

>> +try_tag() {
>> +       tag="$1"
>> +
>> +       # Is $tag an annotated tag?
>> +       [ "$(git cat-file -t "$tag" 2> /dev/null)" = tag ] || return 1
>> +
>> +       # Is it an ancestor of HEAD, and if so, how many commits are in $tag..HEAD?
>> +       # shellcheck disable=SC2046 # word splitting is the point here
>> +       set -- $(git rev-list --count --left-right "$tag"...HEAD 2> /dev/null)
>> +
>> +       # $1 is 0 if and only if $tag is an ancestor of HEAD. Use
>> +       # string comparison, because $1 is empty if the 'git rev-list'
>> +       # command somehow failed.
>> +       [ "$1" = 0 ] || return 1
>> +
>> +       # $2 is the number of commits in the range $tag..HEAD, possibly 0.
>> +       count="$2"
>
> Redundant double-quotes.

Perhaps, but sorry, I'm not code-golfing, and trying to remember when
quotes can be elided when variables are referenced is simply not
something I spend my very limited brain capacity on.

Feel free to make any adjustments you want and commit that, or drop
this, I'm not sending a v5 as that seems to be a waste of everybody's
time.

Rasmus

  reply	other threads:[~2024-11-23 22:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-22 15:00 [PATCH v4] setlocalversion: work around "git describe" performance Rasmus Villemoes
2024-11-22 17:08 ` Josh Poimboeuf
2024-11-23  8:06 ` Masahiro Yamada
2024-11-23 22:12   ` Rasmus Villemoes [this message]
2024-11-24  2:10     ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87iksdk3ag.fsf@prevas.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=peff@peff.net \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.