The branch stable/15 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=45da2c1e1d202ab190f156dd63403be79fb11e94
commit 45da2c1e1d202ab190f156dd63403be79fb11e94 Author: Ed Maste <[email protected]> AuthorDate: 2026-07-01 14:35:10 +0000 Commit: Ed Maste <[email protected]> CommitDate: 2026-07-09 15:18:31 +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 (cherry picked from commit 465a3b7adc008c068741594f6c922ede98924f39) --- 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 7ce82a1af9f8..afd7e8c35d2b 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" ] ; then
