From nobody Thu Apr 28 18:07:03 2022 X-Original-To: dev-commits-src-main@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 153031AADB36; Thu, 28 Apr 2022 18:07:04 +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 4Kq3VJ03Wvz3Fdx; Thu, 28 Apr 2022 18:07:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651169224; 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=m45ct4CNggjx9hAjgt9o9duxs7H4unq9ZA0BFa3IY8E=; b=oMQpqo+4LIUPiDwzCRCNL0hjCNHtxli/KQS9Jqp1zBj2RlcXo9FSRbaek4qqzKzYA0Z46i xDznbTH/D3FLZ6QujpXzDLzV+ioYH5lUOiPwCA8v3VEt6S6t6KsQXXaBbxRqfnpBoB7OCv oqch6c6VO81xgAKtPOzRcDUBEowydPF5pxikrKTsRRiRiRdEmOYi8Woipn4/wSzkoWeZc1 x1VWvRe1/Co15rRS67TVaZPU/HDh2PSnCo6a5/LA8eahxYbT6RdQGMC4az5z76jnf5ZFIZ igI0+v6UXN3a2eMjKnaNdIlpd6/JZsZaHokhfLDRr7ypP0iLDWkbEiCgGUVjEg== 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 D64D81D78D; Thu, 28 Apr 2022 18:07:03 +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 23SI73Rf084776; Thu, 28 Apr 2022 18:07:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23SI73a9084775; Thu, 28 Apr 2022 18:07:03 GMT (envelope-from git) Date: Thu, 28 Apr 2022 18:07:03 GMT Message-Id: <202204281807.23SI73a9084775@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 1a50bf77af90 - main - Add a tool to find MFC candidates List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 1a50bf77af90e0ee7a80f268b2c0bf2a44e38ef2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651169224; 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=m45ct4CNggjx9hAjgt9o9duxs7H4unq9ZA0BFa3IY8E=; b=PPKf5dUp5MfwHZSV2f1CT8H54UllVSyxQCGVthfBPbHYjOcOt/Eue9ukDb7O2avU7zXbw5 uWYRyl2whTqKtCPzDFNHrIra/XMyj0LrbveI8RlI0qqvegwtWC/TfUB4hEi9Bk69vKd1Jg PVj3zjQIinWxDq7/pMpqKtaf5xIUgojQMAJrCw6okjrE9jq3BcWtVc0vdwvIe0g0tSoDF0 it1YgCFqDSyhSrwMtiesHheAlUT34fiH7TWv1CtB8xbC6xTwj+WCQnBkilCUSFFL0lLWUu UesQHQTnrGjbdxD4+SPLhbP3UTWlPkc3gFRJF4ceg4MquM2n+mRaq1dXMftivQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651169224; a=rsa-sha256; cv=none; b=E/YPKu3RDmugCjJtJCaHfG40QAiJn5zYnPLMXyYip5kjfi3thIvpHg3cWGQ2XtRMYHSmhG H8TW7q/x1ku6J2XIPBDcPzimTpVJCKI9pv4/KaR/rRfL8FOV/yFYrAyDy4x6Nih1wNwMii Zc2r1RXaA96ENqyirsobJjflHQAYP/oaOBflhHk4j7lxoQSycUprnZ1opDXyG3sCIc73cO sDIAMCF76LKtL4hVn4VGTeG+ZlUDfXVc5xvgb8SH254Q5pOt92VDltLLlqVUcPNGERXci0 Kz9OLuwBl1yu330wazTqagPd13hrfxZd0wZM3C7nX89fZ/x6x5orYwFmiGrOQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=1a50bf77af90e0ee7a80f268b2c0bf2a44e38ef2 commit 1a50bf77af90e0ee7a80f268b2c0bf2a44e38ef2 Author: Ed Maste AuthorDate: 2022-02-08 19:50:50 +0000 Commit: Ed Maste CommitDate: 2022-04-28 18:02:26 +0000 Add a tool to find MFC candidates usage: mfc-candidates.sh [-ah] [-f from_branch] [-t to_branch] [-u user] [-X exclude_file] [path ...] This tool compares git commit hashes that are in from_branch and not in to_branch with hashes listed in "cherry picked from" lines, finding commits that may be MFC candidates. By default it searches for commits by ${USER} but that can be overridden with -u for a specific user or -a for all. gonzo@'s MFC tracker is a web application that presents this sort of information in a more convenient way, and unlike this script it tracks "MFC After" status and timing. However, it is sometimes useful to be able to perform an offline search against a local repo. Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34208 --- tools/tools/git/mfc-candidates.sh | 163 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) diff --git a/tools/tools/git/mfc-candidates.sh b/tools/tools/git/mfc-candidates.sh new file mode 100644 index 000000000000..623edc7174a1 --- /dev/null +++ b/tools/tools/git/mfc-candidates.sh @@ -0,0 +1,163 @@ +#!/bin/sh + +#- +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright 2022 The FreeBSD Foundation +# +# This software was developed by Ed Maste +# under sponsorship from the FreeBSD Foundation. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted providing that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +from_branch=freebsd/main +to_branch=freebsd/stable/13 +author="${USER}" + +# If pwd is a stable or release branch tree, default to it. +cur_branch=$(git symbolic-ref --short HEAD 2>/dev/null) +case $cur_branch in +stable/*) + to_branch=$cur_branch + ;; +releng/*) + to_branch=$cur_branch + major=${cur_branch#releng/} + major=${major%.*} + from_branch=freebsd/stable/$major +esac + +params() +{ + echo "from: $from_branch" + echo "to: $to_branch" + if [ -n "$author" ]; then + echo "author/committer: $author" + else + echo "author/committer: " + fi +} + +usage() +{ + echo "usage: $(basename $0) [-ah] [-f from_branch] [-t to_branch] [-u user] [-X exclude_file] [path ...]" + echo + params + exit 0 +} + +while getopts "af:ht:u:vX:" opt; do + case $opt in + a) + # All authors/committers + author= + ;; + f) + from_branch=$OPTARG + ;; + h) + usage + ;; + t) + to_branch=$OPTARG + ;; + u) + author=$OPTARG + ;; + v) + verbose=1 + ;; + X) + if [ ! -r "$OPTARG" ]; then + echo "Exclude file $OPTARG not readable" >&2 + exit 1 + fi + exclude_file=$OPTARG + ;; + esac +done +shift $(($OPTIND - 1)) + +if [ $verbose ]; then + params + echo +fi + +authorarg= +if [ -n "$author" ]; then + # Match user ID in the email portion of author or committer + authorarg="--author <${author}@ --committer <${author}@" +fi + +# Commits in from_branch after branch point +commits_from() +{ + git rev-list --first-parent $authorarg $to_branch..$from_branch "$@" |\ + sort +} + +# "cherry picked from" hashes from commits in to_branch after branch point +commits_to() +{ + git log $from_branch..$to_branch --grep 'cherry picked from' "$@" |\ + sed -E -n 's/^[[:space:]]*\(cherry picked from commit ([0-9a-f]+)\)[[:space:]]*$/\1/p' |\ + sort +} + +# Turn a list of short hashes (and optional descriptions) into a list of full +# hashes. +canonicalize_hashes() +{ + while read hash rest; do + if ! git show --pretty=%H --no-patch $hash; then + echo "error parsing hash list" >&2 + exit 1 + fi + done | sort +} + +workdir=$(mktemp -d /tmp/find-mfc.XXXXXXXXXX) +from_list=$workdir/commits-from +to_list=$workdir/commits-to +candidate_list=$workdir/candidates + +if [ -n "$exclude_file" ]; then + exclude_list=$workdir/commits-exclude + canonicalize_hashes < $exclude_file > $exclude_list +fi + +commits_from "$@" > $from_list +commits_to "$@" > $to_list + +comm -23 $from_list $to_list > $candidate_list + +if [ -n "$exclude_file" ]; then + mv $candidate_list $candidate_list.bak + comm -23 $candidate_list.bak $exclude_list > $candidate_list +fi + +# Sort by (but do not print) commit time +while read hash; do + git show --pretty='%ct %h %s' --no-patch $hash +done < $candidate_list | sort -n | cut -d ' ' -f 2- + +rm -rf "$workdir"