]> git.ozlabs.org Git - next-scripts/blobdiff - merge_msg
prompt for the MERG_HEAD sides commits
[next-scripts] / merge_msg
index 0af3424f6b623ab1ca1fe4b83c1ef065861e60ae..0b7c63b5a0a33ad5bb59ff6251f49793d8da8974 100755 (executable)
--- a/merge_msg
+++ b/merge_msg
@@ -11,6 +11,7 @@ gitk --merge -- "$@" &
 tools_dir=$(dirname "$0")
 
 hc=()
+mc=()
 cc=()
 cformat='%(trailers:only=no,valueonly,unfold,key=signed-off-by)%aN <%aE>%n%cN <%cE>'
 
@@ -43,6 +44,20 @@ 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
@@ -60,9 +75,9 @@ between commit$hcs:
 
 $(printf '  %s\n' "${hc[@]}")
 
-from the ${hb[*]} tree$hbs and commit:
+from the ${hb[*]} tree$hbs and commit$mcs:
 
-   ("")
+$(printf '  %s\n' "${mc[@]}")
 
 from the BRANCH tree.