Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Sep 2017 00:44:05 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r323167 - stable/11/sys/conf
Message-ID:  <201709050044.v850i55Z060817@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Tue Sep  5 00:44:04 2017
New Revision: 323167
URL: https://svnweb.freebsd.org/changeset/base/323167

Log:
  MFC r308789 (glebius):
  
  If FreeBSD source tree is a subproject of a bigger project, then .git or
  .hg may reside above FreeBSD sources root.  Provide function findvcs()
  that will climb up and seek for presence of a VCS directory.

Modified:
  stable/11/sys/conf/newvers.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/conf/newvers.sh
==============================================================================
--- stable/11/sys/conf/newvers.sh	Tue Sep  5 00:11:06 2017	(r323166)
+++ stable/11/sys/conf/newvers.sh	Tue Sep  5 00:44:04 2017	(r323167)
@@ -51,6 +51,28 @@ fi
 RELEASE="${REVISION}-${BRANCH}"
 VERSION="${TYPE} ${RELEASE}"
 
+#
+# findvcs dir
+#	Looks up directory dir at world root and up the filesystem
+#
+findvcs()
+{
+	local savedir
+
+	savedir=$(pwd)
+	cd ${SYSDIR}/..
+	while [ $(pwd) != "/" ]; do
+		if [ -d "./$1" ]; then
+			VCSDIR=$(pwd)"/$1"
+			cd ${savedir}
+			return 0
+		fi
+		cd ..
+	done
+	cd ${savedir}
+	return 1
+}
+
 if [ -z "${SYSDIR}" ]; then
     SYSDIR=$(dirname $0)/..
 fi
@@ -154,19 +176,20 @@ for dir in /usr/bin /usr/local/bin; do
 		p4_cmd=${dir}/p4
 	fi
 done
-if [ -d "${SYSDIR}/../.git" ] ; then
+
+if findvcs .git; then
 	for dir in /usr/bin /usr/local/bin; do
 		if [ -x "${dir}/git" ] ; then
-			git_cmd="${dir}/git --git-dir=${SYSDIR}/../.git"
+			git_cmd="${dir}/git --git-dir=${VCSDIR}"
 			break
 		fi
 	done
 fi
 
-if [ -d "${SYSDIR}/../.hg" ] ; then
+if findvcs .hg; then
 	for dir in /usr/bin /usr/local/bin; do
 		if [ -x "${dir}/hg" ] ; then
-			hg_cmd="${dir}/hg -R ${SYSDIR}/.."
+			hg_cmd="${dir}/hg -R ${VCSDIR}"
 			break
 		fi
 	done
@@ -213,7 +236,7 @@ if [ -n "$git_cmd" ] ; then
 	if [ -n "$git_b" ] ; then
 		git="${git}(${git_b})"
 	fi
-	if $git_cmd --work-tree=${SYSDIR}/.. diff-index \
+	if $git_cmd --work-tree=${VCSDIR}/.. diff-index \
 	    --name-only HEAD | read dummy; then
 		git="${git}-dirty"
 		modified=true



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