aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2026-07-01 14:35:10 +0000
committerEd Maste <emaste@FreeBSD.org>2026-07-03 13:34:58 +0000
commit465a3b7adc008c068741594f6c922ede98924f39 (patch)
tree192ade6b5d0476a7d7e9b88225dec5c3b8fb90d1
parentc9d98c0134864d8bc69006b92d34a3b22c940870 (diff)
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
-rw-r--r--sys/conf/newvers.sh28
1 files 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" ] ; then