diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2024-11-19 08:09:06 +0900 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2024-11-28 08:11:56 +0900 |
commit | e2ff1219a5541a22921016219c4d86a6d0190d15 (patch) | |
tree | d460a0e927255493562197651afb163f78ffcf6e /scripts | |
parent | 523f3dbc187a9618d4fd80c2b438e4d490705dcd (diff) | |
download | lwn-e2ff1219a5541a22921016219c4d86a6d0190d15.tar.gz lwn-e2ff1219a5541a22921016219c4d86a6d0190d15.zip |
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 <masahiroy@kernel.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/setlocalversion | 12 |
1 files 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() |