Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Nov 2009 21:57:00 +0000 (UTC)
From:      Max Laier <mlaier@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r198863 - stable/8/sys/conf
Message-ID:  <200911032157.nA3Lv0Qn006582@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mlaier
Date: Tue Nov  3 21:57:00 2009
New Revision: 198863
URL: http://svn.freebsd.org/changeset/base/198863

Log:
  MFC r197334,r197433:
      Extract svn and git version info from git-svn repos.

Modified:
  stable/8/sys/conf/newvers.sh
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/conf/newvers.sh
==============================================================================
--- stable/8/sys/conf/newvers.sh	Tue Nov  3 21:47:07 2009	(r198862)
+++ stable/8/sys/conf/newvers.sh	Tue Nov  3 21:57:00 2009	(r198863)
@@ -89,28 +89,54 @@ i=`${MAKE:-make} -V KERN_IDENT`
 
 case "$d" in
 */sys/*)
+	SRCDIR=${d##*obj}
+	if [ -n "$MACHINE" ]; then
+		SRCDIR=${SRCDIR##/$MACHINE}
+	fi
+	SRCDIR=${SRCDIR%%/sys/*}
+
 	for dir in /bin /usr/bin /usr/local/bin; do
-		if [ -x "${dir}/svnversion" ]; then
+		if [ -d "${SRCDIR}/sys/.svn" -a -x "${dir}/svnversion" ] ; then
 			svnversion=${dir}/svnversion
-			SRCDIR=${d##*obj}
-			if [ -n "$MACHINE" ]; then
-				SRCDIR=${SRCDIR##/$MACHINE}
-			fi
-			SRCDIR=${SRCDIR%%/sys/*}
+			break
+		fi
+		if [ -d "${SRCDIR}/.git" -a -x "${dir}/git" ] ; then
+			git_cmd="${dir}/git --git-dir=${SRCDIR}/.git"
 			break
 		fi
 	done
 
-	if [ -n "$svnversion" -a -d "${SRCDIR}/sys/.svn" ] ; then
+	if [ -n "$svnversion" ] ; then
 		svn=" r`cd ${SRCDIR}/sys && $svnversion`"
 	fi
+	if [ -n "$git_cmd" ] ; then
+		git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null`
+		svn=`$git_cmd svn find-rev $git 2>/dev/null`
+		if [ -n "$svn" ] ; then
+			svn=" r${svn}"
+			git="=${git}"
+		else
+			svn=`$git_cmd log | fgrep 'git-svn-id:' | head -1 | \
+			     sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'`
+			if [ -n $svn ] ; then
+				svn=" r${svn}"
+				git="+${git}"
+			else
+				git=" ${git}"
+			fi
+		fi
+		if $git_cmd --work-tree=${SRCDIR} diff-index \
+		    --name-only HEAD | read dummy; then
+			git="${git}-dirty"
+		fi
+	fi
 	;;
 esac
 
 cat << EOF > vers.c
 $COPYRIGHT
-#define SCCSSTR "@(#)${VERSION} #${v}${svn}: ${t}"
-#define VERSTR "${VERSION} #${v}${svn}: ${t}\\n    ${u}@${h}:${d}\\n"
+#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}: ${t}"
+#define VERSTR "${VERSION} #${v}${svn}${git}: ${t}\\n    ${u}@${h}:${d}\\n"
 #define RELSTR "${RELEASE}"
 
 char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR;



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