setlocalversion: use only the correct release tag for git-describe
authorMasahiro Yamada <masahiroy@kernel.org>
Sun, 5 Feb 2023 12:09:57 +0000 (21:09 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Tue, 14 Feb 2023 17:56:27 +0000 (02:56 +0900)
commit6ab7e1f95e96f0c688ae132b0e9a16c0f206689d
tree47d0c4bbf288eaaf7eaa742c02f1bad57e121b5d
parenteed36d77517786e4b3a9f17c6a66c6df2fc99442
setlocalversion: use only the correct release tag for git-describe

Currently, setlocalversion uses any annotated tag for git-describe.
If we are at a tagged commit, it will not append the commit hash.

  $ git checkout v6.2-rc1^
  $ make -s defconfig kernelrelease
  6.1.0-14595-g292a089d78d3
  $ git tag -a foo -m foo
  $ make -s kernelrelease
  6.1.0

If a local tag 'foo' exists, it pretends to be a released version
'6.1.0', while there are many commits on top of it.

The output should be consistent irrespective of such a local tag.
Pass the correct release tag to --match option of git-describe.

In the mainline kernel, the SUBLEVEL is always '0', which is omitted
from the tag.

  KERNELVERSION      annotated tag
  6.1.0          ->  v6.1            (mainline)
  6.2.0-rc5      ->  v6.2-rc5        (mainline, release candidate)
  6.1.7          ->  v6.1.7          (stable)

To preserve the behavior in linux-next, use the tag derived from
localversion* files if exists. In linux-next, the local version is
specified by the localversion-next file.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/setlocalversion