X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=merge_msg;h=0b7c63b5a0a33ad5bb59ff6251f49793d8da8974;hb=HEAD;hp=e436cd5f24307db791c114777a440e397e3fd82e;hpb=60a1d068ee2fdefa6ccf36fad3d6c91fb9a1d242;p=next-scripts diff --git a/merge_msg b/merge_msg index e436cd5..0b7c63b 100755 --- a/merge_msg +++ b/merge_msg @@ -1,36 +1,92 @@ #!/bin/bash -log=../merge.log -[ -f merge.log ] && log=merge.log -control=../real_control -[ -f real_control ] && control=real_control - -branch="" -[ "$1" = "-t" ] && { - branch=$2 +branch=() +if [ "X$1" = 'X-b' ]; then + branch=( -b "$2" ) shift 2 -} +fi -[ "$branch" ] || { - branch=$(grep '^Merging ' $log | tail -1 | sed 's/^Merging //' | sed 's/ .*$//') - branch=${branch%%/*} -} +gitk --merge -- "$@" & -contact=$(awk -F ' ' '$3=="'"$branch"'" { print $1; }' $control) -greeting=${contact%% *} -greeting=${greeting#\"} -[ "${contact%,*}" = "${contact}" ] || greeting="all" +tools_dir=$(dirname "$0") -file="$*" +hc=() +mc=() +cc=() +cformat='%(trailers:only=no,valueonly,unfold,key=signed-off-by)%aN <%aE>%n%cN <%cE>' -gitk --merge -- $file & -[ "$file" ] && gvim $file +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 -sylpheed --compose "mailto:$contact?Cc=linux-next@vger.kernel.org,%20linux-kernel@vger.kernel.org&Subject=linux-next: manual merge of the $branch tree with the tree&Body=Hi $greeting,%0A\ -%0A\ -Today's linux-next merge of the $branch tree got a conflict 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_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[@]}" <