From owner-svn-src-all@freebsd.org Tue Sep 5 00:44:06 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 13271E05525; Tue, 5 Sep 2017 00:44:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D3BEB67D7A; Tue, 5 Sep 2017 00:44:05 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v850i5G1060818; Tue, 5 Sep 2017 00:44:05 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v850i55Z060817; Tue, 5 Sep 2017 00:44:05 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201709050044.v850i55Z060817@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 5 Sep 2017 00:44:05 +0000 (UTC) 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 X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/sys/conf X-SVN-Commit-Revision: 323167 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2017 00:44:06 -0000 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