Page MenuHomeFreeBSD

D34208.id102684.diff
No OneTemporary

D34208.id102684.diff

Index: tools/tools/git/find-mfc.sh
===================================================================
--- /dev/null
+++ tools/tools/git/find-mfc.sh
@@ -0,0 +1,128 @@
+#!/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
+# t 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/*|releng/*)
+ to_branch=$cur_branch
+ ;;
+esac
+
+params()
+{
+ echo "from: $from_branch"
+ echo "to: $to_branch"
+ if [ -n "$author" ]; then
+ echo "author/committer: $author"
+ else
+ echo "author/committer: <all>"
+ fi
+}
+
+usage()
+{
+ echo "usage: $(basename $0) [-ah] [-f from_branch] [-t to_branch] [-u user] [path ...]"
+ echo
+ params
+ exit 0
+}
+
+while getopts "af:ht:u:v" 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
+ ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+if [ $verbose ]; then
+ params
+ echo
+fi
+
+authorarg=
+if [ -n "$author" ]; then
+ 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
+}
+
+workdir=$(mktemp -d /tmp/find-mfc.XXXXXXXX)
+from_list=$workdir/commits-from
+to_list=$workdir/commits-to
+candidate_list=$workdir/candidates
+
+commits_from "$@" > $from_list
+commits_to "$@" > $to_list
+
+comm -23 $from_list $to_list > $candidate_list
+
+# 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"

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 6, 11:10 PM (3 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31001775
Default Alt Text
D34208.id102684.diff (3 KB)

Event Timeline