X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=merge_msg;h=0b7c63b5a0a33ad5bb59ff6251f49793d8da8974;hb=HEAD;hp=626cf943460a1bd7a8b36a28217f53596cdfeeab;hpb=434a9861e22bd9218ff01e5b5efd60f6f54d2d13;p=next-scripts diff --git a/merge_msg b/merge_msg index 626cf94..0b7c63b 100755 --- a/merge_msg +++ b/merge_msg @@ -1,29 +1,92 @@ #!/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 +tools_dir=$(dirname "$0") -conf="a conflict" -[ "$#" -gt 1 ] && { - file=${file// /, } - file=$(echo $file | sed 's/,\([^,]*\)$/ and\1/') - conf="conflicts" -} +hc=() +mc=() +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" -body="Today's linux-next merge of the BRANCH tree got $conf in $file between commit (%22%22) from the tree and commit (%22%22) from the BRANCH tree.%0A\ -%0A\ -I fixed it up (see below) and can carry the fix as necessary (no action%0A\ -is required)." +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 -$(dirname $0)/message_helper $branch "$subject" "$body" +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[@]}" <