]> git.ozlabs.org Git - next-scripts/blobdiff - merge_msg
update to_build_host a bit
[next-scripts] / merge_msg
index 38e6e2e6113d3494806c5163e24009a946c097b3..0b7c63b5a0a33ad5bb59ff6251f49793d8da8974 100755 (executable)
--- a/merge_msg
+++ b/merge_msg
@@ -1,35 +1,83 @@
 #!/bin/bash
 
-branch=""
-[ "$1" = "-t" ] && {
-        branch="-t $2"
+branch=()
+if [ "X$1" = 'X-b' ]; then
+        branch=( -b "$2" )
         shift 2
-}
+fi
 
 gitk --merge -- "$@" &
-# [ "$#" ] && gvim "$@" 2>/dev/null
 
-printf -v files "  %s\n" "$@"
-conf="a conflict"
-[ "$#" -gt 1 ] &&
-       conf="conflicts"
+tools_dir=$(dirname "$0")
 
-subject="manual merge of the BRANCH tree with the FIXME tree"
+hc=()
+mc=()
+cc=()
+cformat='%(trailers:only=no,valueonly,unfold,key=signed-off-by)%aN <%aE>%n%cN <%cE>'
 
-$(dirname $0)/message_helper $branch "$subject" <<EOF
+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
+hcs=''
+if [ "${#hc[@]}" -gt 1 ]; then
+       hcs='s'
+fi
+
+read -r -a head_branches -p 'HEAD branch(es): '
+
+hb=( "${head_branches[@]/%/,}" )
+hb[-1]=${hb[-1]%,}
+if [ "${#hb[@]}" -gt 2 ]; then
+       hb[-2]=${hb[-2]/%,/ and}
+fi
+hbs=''
+if [ "${#hb[@]}" -gt 1 ]; then
+       hbs='s'
+fi
+
+printf -v subject 'manual merge of the BRANCH tree with the %s tree%s' \
+       "${hb[*]}" "$hbs"
+
+read -r -a merge_commits -p 'MERGE_HEAD commit(s): '
+for c in "${merge_commits[@]}"; do
+       if ! git rev-parse --verify "$c" >/dev/null; then
+               printf 'Unknown commit %s\n' "$c"
+               exit 1
+       fi
+       mc+=( "$(git log -1 --format='%h ("%s")' "$c")" )
+       readarray -t -O "${#cc[@]}" cc < <(git log -1 --format="$cformat" "$c" | sort -u)
+done
+mcs=''
+if [ "${#mc[@]}" -gt 1 ]; then
+       mcs='s'
+fi
+
+printf -v files '  %s\n' "$@"
+conf='a conflict'
+if [ "$#" -gt 1 ]; then
+       conf='conflicts'
+fi
+
+"$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:
+between commit$hcs:
 
-   ("")
+$(printf '  %s\n' "${hc[@]}")
 
-from the FIXME tree and commit:
+from the ${hb[*]} tree$hbs and commit$mcs:
 
-   ("")
+$(printf '  %s\n' "${mc[@]}")
 
 from the BRANCH tree.