Fix newvers.sh to no longer print an outdated SVN rev

We have stopped using SVN, so the notes containing the old SVN revisions
are no longer populated, so fall back to purely counting the number of
commits (currently at about 255337).

Also turn the format more into what git-describe produces, with a name
first, then the number of commits and the hash last. Note that as we
don't tag anything on `main`, git describe will never produce something
useful there and finds the newest vendor tag that was merged in instead.

Sample output:
FreeBSD 13.0-CURRENT #6 main-c255126-gb81783dc98e6-dirty
FreeBSD 12.2-STABLE #0 stable/12-c243035-gd16dac42b641-dirty

MFC after:	3 weeks
Reviewed by:	imp, glebius
Differential Revision:	https://reviews.freebsd.org/D27751
This commit is contained in:
Ulrich Spörlein 2020-12-23 22:29:34 +01:00
parent a2a908ed00
commit 8d405efd73

View File

@ -248,42 +248,19 @@ fi
if [ -n "$git_cmd" ] ; then
git=$($git_cmd rev-parse --verify --short HEAD 2>/dev/null)
gitsvn=$($git_cmd svn find-rev $git 2>/dev/null)
if [ -n "$gitsvn" ] ; then
svn=" r${gitsvn}"
git="=${git}"
else
# Log searches are limited to 10k commits to speed up failures.
# We assume that if a tree is more than 10k commits out-of-sync
# with FreeBSD, it has forked the the OS and the SVN rev no
# longer matters.
gitsvn=$($git_cmd log -n 10000 |
grep '^ git-svn-id:' | head -1 | \
sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p')
if [ -z "$gitsvn" ] ; then
gitsvn=$($git_cmd log -n 10000 --format='format:%N' | \
grep '^svn ' | head -1 | \
sed -n 's/^.*revision=\([0-9][0-9]*\).*$/\1/p')
fi
if [ -n "$gitsvn" ] ; then
svn=" r${gitsvn}"
git="+${git}"
else
git=" ${git}"
fi
fi
git_cnt=$($git_cmd rev-list --count HEAD 2>/dev/null)
if [ -n "$git_cnt" ] ; then
git="${git}-c${git_cnt}"
git="c${git_cnt}-g${git}"
fi
git_b=$($git_cmd rev-parse --abbrev-ref HEAD)
if [ -n "$git_b" ] ; then
git="${git}(${git_b})"
if [ -n "$git_b" -a "$git_b" != "HEAD" ] ; then
git="${git_b}-${git}"
fi
if git_tree_modified; then
git="${git}-dirty"
modified=yes
fi
git=" ${git}"
fi
if [ -n "$hg_cmd" ] ; then