From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Masahiro Yamada <masahiroy@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] setlocalversion: add -e option
Date: Tue, 19 Nov 2024 08:09:06 +0900 [thread overview]
Message-ID: <20241118231534.1351938-1-masahiroy@kernel.org> (raw)
Set the -e option to ensure this script fails on any unexpected errors.
Without this change, the kernel build may continue running with an
incorrect string in include/config/kernel.release.
Currently, try_tag() returns 1 when the expected tag is not found as an
ancestor, but this is a case where the script should continue.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
After '[PATCH v3] setlocalversion: work around "git describe" performance',
I need to remove "|| return 1" statements anyway, as it is not suitable
for the -e option.
if []; then
...
fi
is more consistent with the existing code.
scripts/setlocalversion | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 5818465abba9..28169d7e143b 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -10,6 +10,8 @@
#
#
+set -e
+
usage() {
echo "Usage: $0 [--no-local] [srctree]" >&2
exit 1
@@ -34,7 +36,9 @@ try_tag() {
tag="$1"
# Is $tag an annotated tag?
- [ "$(git cat-file -t "$tag" 2> /dev/null)" = tag ] || return 1
+ if [ "$(git cat-file -t "$tag" 2> /dev/null)" != tag ]; then
+ return
+ fi
# 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
@@ -43,12 +47,12 @@ try_tag() {
# $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
+ if [ "$1" != 0 ]; then
+ return
+ fi
# $2 is the number of commits in the range $tag..HEAD, possibly 0.
count="$2"
-
- return 0
}
scm_version()
--
2.43.0
next reply other threads:[~2024-11-18 23:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 23:09 Masahiro Yamada [this message]
2024-11-26 13:11 ` 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=20241118231534.1351938-1-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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®