Skip to content

Commit e2ff121

Browse files
committed
setlocalversion: add -e option
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 <[email protected]>
1 parent 523f3db commit e2ff121

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scripts/setlocalversion

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#
1111
#
1212

13+
set -e
14+
1315
usage() {
1416
echo "Usage: $0 [--no-local] [srctree]" >&2
1517
exit 1
@@ -34,7 +36,9 @@ try_tag() {
3436
tag="$1"
3537

3638
# Is $tag an annotated tag?
37-
[ "$(git cat-file -t "$tag" 2> /dev/null)" = tag ] || return 1
39+
if [ "$(git cat-file -t "$tag" 2> /dev/null)" != tag ]; then
40+
return
41+
fi
3842

3943
# Is it an ancestor of HEAD, and if so, how many commits are in $tag..HEAD?
4044
# shellcheck disable=SC2046 # word splitting is the point here
@@ -43,12 +47,12 @@ try_tag() {
4347
# $1 is 0 if and only if $tag is an ancestor of HEAD. Use
4448
# string comparison, because $1 is empty if the 'git rev-list'
4549
# command somehow failed.
46-
[ "$1" = 0 ] || return 1
50+
if [ "$1" != 0 ]; then
51+
return
52+
fi
4753

4854
# $2 is the number of commits in the range $tag..HEAD, possibly 0.
4955
count="$2"
50-
51-
return 0
5256
}
5357

5458
scm_version()

0 commit comments

Comments
 (0)