git: 6756f09d73de - stable/14 - newvers.sh: Avoid spurious -dirty in git revision
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 09 Jul 2026 15:19:53 UTC
The branch stable/14 has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=6756f09d73de7d876501a7f24f07fb362aec35f3
commit 6756f09d73de7d876501a7f24f07fb362aec35f3
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2026-07-01 14:35:10 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-07-09 15:19:35 +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)
(cherry picked from commit 45da2c1e1d202ab190f156dd63403be79fb11e94)
---
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 e90e1ef79902..5b5e390228f7 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -262,21 +262,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