From: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org,
Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Matthias Maennich <maennich@google.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] scripts/setlocalversion: factor out 12-chars hash construction
Date: Sun, 23 May 2021 11:04:40 +0200 [thread overview]
Message-ID: <87tumt6ct3.fsf@ungleich.ch> (raw)
In-Reply-To: <20210523031428.164186-4-masahiroy@kernel.org>
Hey Masahiro,
Masahiro Yamada <masahiroy@kernel.org> writes:
> - if atag="$(git describe --abbrev=12 2>/dev/null)"; then
> - echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),substr($(NF),0,13))}'
> -
> - # If we don't have a tag at all we print -g{commitish},
> - # again using exactly 12 hex chars.
> - else
> - head="$(echo $head | cut -c1-12)"
> - printf '%s%s' -g $head
> + if atag="$(git describe 2>/dev/null)"; then
> + echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}'
> fi
> +
> + # Add -g and exactly 12 hex chars.
> + printf '%s%s' -g "$(echo $head | cut -c1-12)"
> fi
>
> # Check for uncommitted changes.
That was quite fun reviewing and wrapping my head around ~20y old code.
I had a very long mail prepared looking at all the corner cases, just to
see they are actually handled before the actual change.
Nicely simplified, for all 5 of them:
Reviewed-by: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>
--
Sustainable and modern Infrastructures by ungleich.ch
next prev parent reply other threads:[~2021-05-23 9:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-23 3:14 [PATCH 1/5] scripts/setlocalversion: remove mercurial, svn and git-svn supports Masahiro Yamada
2021-05-23 3:14 ` [PATCH 2/5] scripts/setlocalversion: remove workaround for old make-kpkg Masahiro Yamada
2021-05-23 3:14 ` [PATCH 3/5] scripts/setlocalversion: add more comments to -dirty flag detection Masahiro Yamada
2021-05-23 3:14 ` [PATCH 4/5] scripts/setlocalversion: factor out 12-chars hash construction Masahiro Yamada
2021-05-23 9:04 ` Nico Schottelius [this message]
2021-05-23 3:14 ` [PATCH 5/5] scripts/setlocalversion: simplify the short version part Masahiro Yamada
2021-05-23 7:48 ` [PATCH 1/5] scripts/setlocalversion: remove mercurial, svn and git-svn supports Greg Kroah-Hartman
2021-05-26 14:29 ` 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=87tumt6ct3.fsf@ungleich.ch \
--to=nico-linuxsetlocalversion@schottelius.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=maennich@google.com \
--cc=masahiroy@kernel.org \
--cc=mpe@ellerman.id.au \
/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.