From e1b1448c210ddb68efc365fce049640243cd2bbd Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 2 Oct 2020 10:12:28 +1000 Subject: [PATCH] merge_msg: prompt for the HEAD side commits Insert these commit logs into the message. Also add email addresses associated with them to the Cc list and pass them down. --- merge_msg | 18 ++++++++++++++++-- message_helper | 12 ++++++++---- send_email | 15 +++++++++++++-- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/merge_msg b/merge_msg index 7ab7c17..011b699 100755 --- a/merge_msg +++ b/merge_msg @@ -10,6 +10,20 @@ gitk --merge -- "$@" & tools_dir=$(dirname "$0") +hc=() +cc=() +cformat='%(trailers:only=no,valueonly,unfold,key=signed-off-by)%aN <%aE>%n%cN <%cE>' + +read -r -a head_commits -p 'HEAD commit(s): ' +for c in "${head_commits[@]}"; do + if ! git rev-parse --verify "$c" >/dev/null; then + printf 'Unknown commit %s\n' "$c" + exit 1 + fi + hc+=( "$(git log -1 --format='%h ("%s")' "$c")" ) + readarray -t -O "${#cc[@]}" cc < <(git log -1 --format="$cformat" "$c" | sort -u) +done + printf -v files ' %s\n' "$@" conf='a conflict' if [ "$#" -gt 1 ]; then @@ -18,7 +32,7 @@ fi subject='manual merge of the BRANCH tree with the FIXME tree' -"$tools_dir/message_helper" "${branch[@]}" "$subject" <' - 'Linux Kernel Mailing List ' ) + 'Linux Kernel Mailing List ' + "$@" ) if [ -z "$branch" ]; then branch=$(grep '^Merging ' "$log" | tail -n 1 | @@ -29,15 +33,15 @@ if [ -z "$branch" ]; then fi contact=$(get_contacts "$branch") -subject=${1//BRANCH/$branch} -filter=( -e "s/BRANCH/$branch/g" ) +subject=${subject//BRANCH/$branch} +filter=( -E -e 's/^([^ ])/|\1/' -e "s/BRANCH/$branch/g" ) if [ -n "$kconfig" ]; then filter+=( -e "s/KCONFIG_NAME/$kconfig/g" ) fi { printf 'Hi all,\n\n' - sed "${filter[@]}" | fmt -s + sed "${filter[@]}" | fmt -w 76 -u -p '|' | sed 's/^|//' } | "$bin_dir"/send_email "linux-next: $subject" "$contact" "${cc[@]}" exit 0 diff --git a/send_email b/send_email index 1c0fc4b..b2b1b54 100755 --- a/send_email +++ b/send_email @@ -1,16 +1,27 @@ #!/bin/bash mail_dir=$(realpath --relative-to=. "$(dirname "$0")/../mails") -printf -v TARGET '%s/%(i%Y-%m-%d+%s)T.email' "$mail_dir" -1 +printf -v TARGET '%s/%(%Y-%m-%d+%s)T.email' "$mail_dir" -1 subject="$1" shift to="$1" shift +readarray -t cc < <(printf '%s\n' "$@" | sort -u) + +for i in "${!cc[@]}"; do + e=${cc[$i]##*<} + e=${e%%>*} + if grep -q -F "<$e>" <<<"$to"; then + unset "cc[$i]" + fi +done { printf 'To: %s\n' "$to" - printf 'Cc: %s\n' "$@" + if [ "${#cc[@]}" -gt 0 ]; then + printf 'Cc: %s\n' "${cc[@]}" + fi printf 'Subject: %s\n\n' "$subject" cat } > "$TARGET" -- 2.39.5