]> git.ozlabs.org Git - next-scripts/commitdiff
merge_msg: prompt for the HEAD side commits
authorStephen Rothwell <sfr@canb.auug.org.au>
Fri, 2 Oct 2020 00:12:28 +0000 (10:12 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 2 Oct 2020 00:12:28 +0000 (10:12 +1000)
Insert these commit logs into the message.  Also add email addresses
associated with them to the Cc list and pass them down.

merge_msg
message_helper
send_email

index 7ab7c176e23bcc0ae3162d94f81e8fc250da89d6..011b6994279026e1db099c5685b2ab69739b494e 100755 (executable)
--- 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" <<EOF
+"$tools_dir/message_helper" "${branch[@]}" "$subject" "${cc[@]}" <<EOF
 FIXME: Add owner of second tree to To:
        Add author(s)/SOB of conflicting commits.
 
@@ -27,7 +41,7 @@ Today's linux-next merge of the BRANCH tree got $conf in:
 $files
 between commit:
 
-   ("")
+$(printf '  %s\n' "${hc[@]}")
 
 from the FIXME tree and commit:
 
index 4224734bc19d0d9c39a592596537e2dd7328d8a7..d13360a7a22f02e818af672d9779e1f7923228ac 100755 (executable)
@@ -20,8 +20,12 @@ if [ "$1" = '-c' ]; then
         shift 2
 fi
 
+subject="$1"
+shift
+
 cc=( 'Linux Next Mailing List <linux-next@vger.kernel.org>'
-       'Linux Kernel Mailing List <linux-kernel@vger.kernel.org>' )
+       'Linux Kernel Mailing List <linux-kernel@vger.kernel.org>'
+       "$@" )
 
 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
index 1c0fc4b0e12ccb114c07d43a93c8f3f90e737be0..b2b1b54cb92927973c1d01bc67fbb1cd2f9a7ea4 100755 (executable)
@@ -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"