Date: Fri, 03 Jul 2026 13:35:21 +0000 From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 465a3b7adc00 - main - newvers.sh: Avoid spurious -dirty in git revision Message-ID: <6a47ba99.3a9d2.1dbc3662@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=465a3b7adc008c068741594f6c922ede98924f39 commit 465a3b7adc008c068741594f6c922ede98924f39 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2026-07-01 14:35:10 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2026-07-03 13:34:58 +0000 newvers.sh: Avoid spurious -dirty in git revision If git is installed and .git exists but git rev-parse failed to report a hash we previously produced just "-dirty" as the git revision. Gate the git commit count and -dirty check on the rev-parse passing. Reviewed by: jlduran Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57995 --- sys/conf/newvers.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 145377c1e75e..de696a192853 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -260,21 +260,23 @@ fi if [ -n "$git_cmd" ] ; then git=$($git_cmd rev-parse --verify --short=12 HEAD 2>/dev/null) - if [ "$($git_cmd rev-parse --is-shallow-repository)" = false ] ; then - git_cnt=$($git_cmd rev-list --first-parent --count HEAD 2>/dev/null) - if [ -n "$git_cnt" ] ; then - git="n${git_cnt}-${git}" + if [ $? -eq 0 ]; then + if [ "$($git_cmd rev-parse --is-shallow-repository)" = false ] ; then + git_cnt=$($git_cmd rev-list --first-parent --count HEAD 2>/dev/null) + if [ -n "$git_cnt" ] ; then + git="n${git_cnt}-${git}" + fi fi + git_b=$($git_cmd rev-parse --abbrev-ref HEAD) + 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 - git_b=$($git_cmd rev-parse --abbrev-ref HEAD) - 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 "$gituprevision" ] ; thenhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a47ba99.3a9d2.1dbc3662>
