Date: Fri, 18 Nov 2016 00:13:30 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308789 - head/sys/conf Message-ID: <201611180013.uAI0DU57087971@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Fri Nov 18 00:13:30 2016 New Revision: 308789 URL: https://svnweb.freebsd.org/changeset/base/308789 Log: 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. Reviewed by: imp (earlier version of the patch) Modified: head/sys/conf/newvers.sh Modified: head/sys/conf/newvers.sh ============================================================================== --- head/sys/conf/newvers.sh Thu Nov 17 23:16:56 2016 (r308788) +++ head/sys/conf/newvers.sh Fri Nov 18 00:13:30 2016 (r308789) @@ -39,6 +39,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 @@ -142,19 +164,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 @@ -193,7 +216,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" fi
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611180013.uAI0DU57087971>