From nobody Tue Sep 06 19:08:27 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MMZfg5h5fz4bT5P; Tue, 6 Sep 2022 19:08:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MMZfg558Rz3cNT; Tue, 6 Sep 2022 19:08:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662491307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xw+vdII4V+BQh5WIzTPCEG/LkXmGcKV3frzO2DJkEqE=; b=lmM6PAHp1D/NSHEN0IxFUlNjmqrk+UodrYDFMsV13aoYnToZnCS8t3Vp9KvKSFS7AwMipO CnUs0p/WIhcPxgxSDiGcjIHuoNSJ23RJjrjVLI/QxHktUqvUszi9qm/oC3li0bwhSjcwiX QV6KMEO0Z6M43xYu3RFYjNTomcWixZihE4JeAWmZTbSu7mtNYV2PmAbIr8qKzxXPHUJAFd aOBqGwfcUUGpoW1YHsKcUOcFT6hv/hVs15qywbXZtI1UwFqztQ+NQ9o6ehgk/3CjxS1Glo TGgG5dpz+CiYu3SlBH2dI6I1gtPZX3qOi4eT3E27rd6SKXNSqxJU8d6mGTKeGg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MMZfg45kXzH0y; Tue, 6 Sep 2022 19:08:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 286J8RKR009663; Tue, 6 Sep 2022 19:08:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 286J8Rkt009662; Tue, 6 Sep 2022 19:08:27 GMT (envelope-from git) Date: Tue, 6 Sep 2022 19:08:27 GMT Message-Id: <202209061908.286J8Rkt009662@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: b67bd2859d7d - stable/12 - newvers.sh: fix git false positive -dirty tag List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: b67bd2859d7d757ee9ceb8269a5790f4f1091be5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662491307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xw+vdII4V+BQh5WIzTPCEG/LkXmGcKV3frzO2DJkEqE=; b=ho0JNX5b32E0nkb0RUID9Znx6sawvyBTmv6KOJAEKEehmzNwgdbrFQ8MTFAaeVxOztfVKE qObMcKY3w3DxKw72aIUHWY+l+TwNJjPzgxG0PFoLLUWe0reBVh6+gwOJ42Aesjsr1ziNfE F6g2fMuLkxOSyR5K/rzex6RSWXdCh8Y34PquheHjat4AaMi3tUpXZkVrAUQSWAc258SvJr GneGZ9v6qdUg5qQnq0Wq4pgS985RvAjlwMXpVig2Pf8d6N7SbU+6JqciAngcvshcZm25vO OiaaCXFgYH3NsFEoaySpBGcek4GOCCIuagFnkL+QYB/yIg2vd9uEyxvSif5Z0Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662491307; a=rsa-sha256; cv=none; b=etlzFhsXZ5vfeoj6Ik10I5PYgiTLuf5XQq9ISOpiya6JFTWoUhuzcOqWNxhBiXdE7QHExD h75LVqfPX4AJjHTNEYQCj/G3jBJw02NHHI3iIZmIVM4vrYlB0NA2KiAa24zmc0xMcmsWtG hvHGr2pGKI2eukUP1+pjhnxpHmvjWYohrxA6vP2DGSOvfN0PYDZJEl2mnF9aBgJbM1tiWB 4DmYR9G6jo5Y3DB1fm4c4OuRwGTpvn0Pj5CnsKFDTmr7mJikr8JgBq+8SkuPHBLxwCJPkG 5sBHM5bPztyeqLgMHv87iDRbWZinQ09dShBAauL0HEYyjJMVoAZye/jViTZ31Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=b67bd2859d7d757ee9ceb8269a5790f4f1091be5 commit b67bd2859d7d757ee9ceb8269a5790f4f1091be5 Author: Ed Maste AuthorDate: 2018-11-02 21:20:46 +0000 Commit: Ed Maste CommitDate: 2022-09-06 17:15:05 +0000 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 (cherry picked from commit 50b53a8dc35f38ab6920dd83409541e875d01551) (cherry picked from commit 5186028dc4a2a74d007fa65857667efb2742eaea) --- sys/conf/newvers.sh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 751d395ad519..e1aa29f8d98d 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -79,6 +79,34 @@ 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 + + fifo=$(mktemp -u) + mkfifo -m 600 $fifo + $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 --work-tree=${VCSTOP} diff --quiet -- "${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 @@ -219,8 +247,7 @@ if [ -n "$git_cmd" ] ; then if [ -n "$git_b" -a "$git_b" != "HEAD" ] ; then git="${git_b}-${git}" 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