Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Jan 2021 09:49:48 GMT
From:      Ulrich Spörlein <uqs@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a9fc14fbf445 - main - newvers.sh: add support for gitup(1)
Message-ID:  <202101200949.10K9nmkZ029085@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by uqs:

URL: https://cgit.FreeBSD.org/src/commit/?id=a9fc14fbf445cffd18f34f6a602bdba84bb5a867

commit a9fc14fbf445cffd18f34f6a602bdba84bb5a867
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2021-01-05 10:48:39 +0000
Commit:     Ulrich Spörlein <uqs@FreeBSD.org>
CommitDate: 2021-01-20 09:48:27 +0000

    newvers.sh: add support for gitup(1)
    
    gitup writes a .gituprevision file into the shallow clone directory. Read that
    file and print commit information only.
    
    Submitted by:   Michael Osipov <michael.osipov@siemens.com>
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/449
    
    While here, drop the redundant branch name from the git output and don't
    count commits in shallow clones.
    
    Reported by:    Michael Osipov <michael.osipov@siemens.com>
    MFC after:      2 weeks
---
 sys/conf/newvers.sh | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index 2a0ace45f2f6..92c275d19fb9 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -221,6 +221,10 @@ if findvcs .git; then
 	done
 fi
 
+if findvcs .gituprevision; then
+	gituprevision="${VCSTOP}/.gituprevision"
+fi
+
 if findvcs .hg; then
 	for dir in /usr/bin /usr/local/bin; do
 		if [ -x "${dir}/hg" ] ; then
@@ -248,13 +252,11 @@ fi
 
 if [ -n "$git_cmd" ] ; then
 	git=$($git_cmd rev-parse --verify --short HEAD 2>/dev/null)
-	git_cnt=$($git_cmd rev-list --count HEAD 2>/dev/null)
-	if [ -n "$git_cnt" ] ; then
-		git="c${git_cnt}-g${git}"
-	fi
-	git_b=$($git_cmd rev-parse --abbrev-ref HEAD)
-	if [ -n "$git_b" -a "$git_b" != "HEAD" ] ; then
-		git="${git_b}-${git}"
+	if [ "$(git rev-parse --is-shallow-repository)" = false ] ; then
+		git_cnt=$($git_cmd rev-list --count HEAD 2>/dev/null)
+		if [ -n "$git_cnt" ] ; then
+			git="c${git_cnt}-g${git}"
+		fi
 	fi
 	if git_tree_modified; then
 		git="${git}-dirty"
@@ -263,6 +265,10 @@ if [ -n "$git_cmd" ] ; then
 	git=" ${git}"
 fi
 
+if [ -n "$gituprevision" ] ; then
+	gitup=" $(awk -F: '{print $2}' $gituprevision)"
+fi
+
 if [ -n "$hg_cmd" ] ; then
 	hg=$($hg_cmd id 2>/dev/null)
 	hgsvn=$($hg_cmd svn info 2>/dev/null | \
@@ -277,10 +283,10 @@ fi
 
 [ ${include_metadata} = "if-modified" -a ${modified} = "yes" ] && include_metadata=yes
 if [ ${include_metadata} != "yes" ]; then
-	VERINFO="${VERSION}${svn}${git}${hg} ${i}"
+	VERINFO="${VERSION}${svn}${git}${gitup}${hg} ${i}"
 	VERSTR="${VERINFO}\\n"
 else
-	VERINFO="${VERSION} #${v}${svn}${git}${hg}: ${t}"
+	VERINFO="${VERSION} #${v}${svn}${git}${gitup}${hg}: ${t}"
 	VERSTR="${VERINFO}\\n    ${u}@${h}:${d}\\n"
 fi
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101200949.10K9nmkZ029085>