From: Jeff King <peff@peff.net>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
Masahiro Yamada <masahiroy@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] setlocalversion: work around "git describe" performance
Date: Wed, 6 Nov 2024 16:23:37 -0500 [thread overview]
Message-ID: <20241106212337.GA956489@coredump.intra.peff.net> (raw)
In-Reply-To: <20241106012838.435040-1-linux@rasmusvillemoes.dk>
On Wed, Nov 06, 2024 at 02:28:38AM +0100, Rasmus Villemoes wrote:
> This has been acknowledged as a performance bug in git [1]. However,
> no solution is yet in git.git, and even when one lands, it will take
> quite a while before it finds its way to a release and for
> $random_kernel_developer to pick that up.
I just posted patches in:
https://lore.kernel.org/git/20241106192236.GC880133@coredump.intra.peff.net/
but I agree it is worth dealing with in the interim. And also, I really
suspect that this new code may end up faster than git-describe in some
cases anyway.
> +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?
> + read left right <<EOF || return 1
> +$(git rev-list --count --left-right "$tag"...HEAD 2> /dev/null)
> +EOF
> +
> + # $left is 0 if and only if $tag is an ancestor of HEAD
> + [ "$left" -eq 0 ] || return 1
> +
> + # $right is the number of commits in the range $tag..HEAD, possibly 0.
> + count="$right"
> +
> + return 0
> +}
The git parts all look good to me here (and not knowing much about the
kernel's scripts I'll refrain from even looking closely at the other
parts).
The use of the here-doc is a little funny, but I guess you can't just
pipe to read since that would put it in a subshell. But I do note that
your "|| return 1" won't catch a failure from "rev-list", if that was
the intent. I think you'd have to use a real tempfile to catch it, or
play horrid tricks with echoing $? into the "read" stream. I guess the
explicit check for "$left -eq 0" will catch most failures anyway.
If you use "<<-" you can get rid of the awkward indentation.
-Peff
next prev parent reply other threads:[~2024-11-06 21:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 1:28 Rasmus Villemoes
2024-11-06 21:23 ` Jeff King [this message]
2024-11-07 10:52 ` Rasmus Villemoes
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=20241106212337.GA956489@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=masahiroy@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®