Index: tools/tools/git/find-mfc.sh =================================================================== --- /dev/null +++ tools/tools/git/find-mfc.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +from_branch=freebsd/main +to_branch=freebsd/stable/13 +author=$USER + +usage() +{ + echo "usage: $(basename $0) [-ah] [-f from_branch] [-t to_branch] [-u user] [path ...]" + exit 0 +} + +while getopts "af:ht:u:" opt; do + case $opt in + a) + author= + ;; + f) + from_branch=$OPTARG + ;; + h) + usage + ;; + t) + to_branch=$OPTARG + ;; + u) + author=$OPTARG + ;; + esac +done +shift $(($OPTIND - 1)) + +authorarg= +if [ -n "$author" ]; then + authorarg="--author $author --committer $author" +fi + +# Commits in from_branch after branch point +git rev-list --first-parent $authorarg $to_branch..$from_branch "$@" |\ + sort > from_list + +# "cherry picked from" hashes from commits in to_branch after branch point +git log $authorarg $from_branch..$to_branch --grep 'cherry picked from' "$@" |\ + sed -E -n 's/^[[:space:]]*\(cherry picked from commit ([0-9a-f]+)\)[[:space:]]*$/\1/p' |\ + sort > to_list + +comm -23 from_list to_list > candidates + +while read x; do + git show --pretty='%ct %h %s' --no-patch $x +done < candidates | sort -n | cut -d ' ' -f 2-