From owner-svn-src-all@freebsd.org Fri Nov 2 21:20:47 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30FE210DBA90; Fri, 2 Nov 2018 21:20:47 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DB2687F196; Fri, 2 Nov 2018 21:20:46 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BC42110479; Fri, 2 Nov 2018 21:20:46 +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 wA2LKkUT066739; Fri, 2 Nov 2018 21:20:46 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wA2LKkdQ066738; Fri, 2 Nov 2018 21:20:46 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201811022120.wA2LKkdQ066738@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 2 Nov 2018 21:20:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r340083 - head/sys/conf X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/sys/conf X-SVN-Commit-Revision: 340083 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.29 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: Fri, 02 Nov 2018 21:20:47 -0000 Author: emaste Date: Fri Nov 2 21:20:46 2018 New Revision: 340083 URL: https://svnweb.freebsd.org/changeset/base/340083 Log: newvers.sh: fix git false positive -dirty tag Assuming that any output from `git diff-index --name-only` implies changes in the working tree results in false positives: files with metadata, but not content, changes are also listed. Check that content differences exist before adding the -dirty tag to the git hash. PR: 229230 Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D15968 Modified: head/sys/conf/newvers.sh Modified: head/sys/conf/newvers.sh ============================================================================== --- head/sys/conf/newvers.sh Fri Nov 2 21:07:06 2018 (r340082) +++ head/sys/conf/newvers.sh Fri Nov 2 21:20:46 2018 (r340083) @@ -76,6 +76,35 @@ findvcs() return 1 } +git_tree_modified() +{ + # git diff-index lists both files that are known to have changes as + # well as those with metadata that does not match what is recorded in + # git's internal state. The latter case is indicated by an all-zero + # destination file hash. + + local fifo vcstop_abs + + fifo=$(mktemp -u) + mkfifo -m 600 $fifo + vcstop_abs=$(realpath $VCSTOP) + $git_cmd --work-tree=${VCSTOP} diff-index HEAD > $fifo & + while read smode dmode ssha dsha status file; do + if ! expr $dsha : '^00*$' >/dev/null; then + rm $fifo + return 0 + fi + if ! $git_cmd diff --quiet -- "${vcstop_abs}/${file}"; then + rm $fifo + return 0 + fi + done < $fifo + # No files with content differences. + rm $fifo + return 1 +} + + if [ -z "${SYSDIR}" ]; then SYSDIR=$(dirname $0)/.. fi @@ -240,8 +269,7 @@ if [ -n "$git_cmd" ] ; then if [ -n "$git_b" ] ; then git="${git}(${git_b})" fi - if $git_cmd --work-tree=${VCSTOP} diff-index \ - --name-only HEAD | read dummy; then + if git_tree_modified; then git="${git}-dirty" modified=true fi