]> git.ozlabs.org Git - next-scripts/blobdiff - merge_msg
merge_msg: prompt for the HEAD side commits
[next-scripts] / merge_msg
index f5dc1d497f0c00113ecf9e4cc79aacdb9d89c4e9..011b6994279026e1db099c5685b2ab69739b494e 100755 (executable)
--- a/merge_msg
+++ b/merge_msg
@@ -1,30 +1,60 @@
 #!/bin/bash
 
-branch=""
-[ "$1" = "-t" ] && {
-        branch="-t $2"
+branch=()
+if [ "X$1" = 'X-b' ]; then
+        branch=( -b "$2" )
         shift 2
-}
+fi
 
-file="$*"
+gitk --merge -- "$@" &
 
-gitk --merge -- $file &
-[ "$file" ] && gvim $file 2>/dev/null
+tools_dir=$(dirname "$0")
 
-conf="a conflict"
-[ "$#" -gt 1 ] && {
-       file=${file// /, }
-       file=$(echo $file | sed 's/,\([^,]*\)$/ and\1/')
-       conf="conflicts"
-}
+hc=()
+cc=()
+cformat='%(trailers:only=no,valueonly,unfold,key=signed-off-by)%aN <%aE>%n%cN <%cE>'
 
-subject="manual merge of the BRANCH tree with the  tree"
+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
 
-$(dirname $0)/message_helper $branch "$subject" <<EOF
-Today's linux-next merge of the BRANCH tree got $conf in $file between commit  ("") from the  tree and commit  ("") from the BRANCH tree.
+printf -v files '  %s\n' "$@"
+conf='a conflict'
+if [ "$#" -gt 1 ]; then
+       conf='conflicts'
+fi
 
-I fixed it up (see below) and can carry the fix as necessary (no action
-is required).
+subject='manual merge of the BRANCH tree with the FIXME tree'
+
+"$tools_dir/message_helper" "${branch[@]}" "$subject" "${cc[@]}" <<EOF
+FIXME: Add owner of second tree to To:
+       Add author(s)/SOB of conflicting commits.
+
+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:
+
+   ("")
+
+from the BRANCH tree.
+
+I fixed it up (see below) and can carry the fix as necessary. This
+is now fixed as far as linux-next is concerned, but any non trivial
+conflicts should be mentioned to your upstream maintainer when your tree
+is submitted for merging.  You may also want to consider cooperating
+with the maintainer of the conflicting tree to minimise any particularly
+complex conflicts.
 EOF
 
 exit 0