From 2cb541bf69b7759988655f180afd4d76d0d1197e Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 4 Jan 2019 14:42:36 +0000 Subject: [PATCH] newvers: avoid clearing svn revision information with nested VCS dirs Consider the case where FreeBSD is checked out via Subversion with a (perhaps unrelated) .git or .hg directory at a higher level - for example, .../.git .../src/freebsd Previously newvers obtained the SVN revision information via svnversion, and then tried to obtain the SVN revision corresponding to the git or hg commit, overwriting the existing information. As a short term fix use a different variable for hg-svn or git-svn information, setting $svn from hg or git info only if not empty. Reported by: Matthias Apitz Sponsored by: The FreeBSD Foundation --- sys/conf/newvers.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 643ccb73fb3..7e92ae465b4 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -244,21 +244,21 @@ 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}" + gitsvn=`$git_cmd svn find-rev $git 2>/dev/null` + if [ -n "$gitsvn" ] ; then + svn=" r${gitsvn}" git="=${git}" else - svn=`$git_cmd log --grep '^git-svn-id:' | \ + gitsvn=`$git_cmd log --grep '^git-svn-id:' | \ grep '^ git-svn-id:' | head -1 | \ sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'` - if [ -z "$svn" ] ; then - svn=`$git_cmd log --format='format:%N' | \ + if [ -z "$gitsvn" ] ; then + gitsvn=`$git_cmd log --format='format:%N' | \ grep '^svn ' | head -1 | \ sed -n 's/^.*revision=\([0-9][0-9]*\).*$/\1/p'` fi - if [ -n "$svn" ] ; then - svn=" r${svn}" + if [ -n "$gitsvn" ] ; then + svn=" r${gitsvn}" git="+${git}" else git=" ${git}" @@ -295,10 +295,10 @@ fi if [ -n "$hg_cmd" ] ; then hg=`$hg_cmd id 2>/dev/null` - svn=`$hg_cmd svn info 2>/dev/null | \ + hgsvn=`$hg_cmd svn info 2>/dev/null | \ awk -F': ' '/Revision/ { print $2 }'` - if [ -n "$svn" ] ; then - svn=" r${svn}" + if [ -n "$hgsvn" ] ; then + svn=" r${hgsvn}" fi if [ -n "$hg" ] ; then hg=" ${hg}"