]> git.ozlabs.org Git - next-scripts/blob - merge_msg
merge_msg: prompt for the HEAD side commits
[next-scripts] / merge_msg
1 #!/bin/bash
2
3 branch=()
4 if [ "X$1" = 'X-b' ]; then
5         branch=( -b "$2" )
6         shift 2
7 fi
8
9 gitk --merge -- "$@" &
10
11 tools_dir=$(dirname "$0")
12
13 hc=()
14 cc=()
15 cformat='%(trailers:only=no,valueonly,unfold,key=signed-off-by)%aN <%aE>%n%cN <%cE>'
16
17 read -r -a head_commits -p 'HEAD commit(s): '
18 for c in "${head_commits[@]}"; do
19         if ! git rev-parse --verify "$c" >/dev/null; then
20                 printf 'Unknown commit %s\n' "$c"
21                 exit 1
22         fi
23         hc+=( "$(git log -1 --format='%h ("%s")' "$c")" )
24         readarray -t -O "${#cc[@]}" cc < <(git log -1 --format="$cformat" "$c" | sort -u)
25 done
26
27 printf -v files '  %s\n' "$@"
28 conf='a conflict'
29 if [ "$#" -gt 1 ]; then
30         conf='conflicts'
31 fi
32
33 subject='manual merge of the BRANCH tree with the FIXME tree'
34
35 "$tools_dir/message_helper" "${branch[@]}" "$subject" "${cc[@]}" <<EOF
36 FIXME: Add owner of second tree to To:
37        Add author(s)/SOB of conflicting commits.
38
39 Today's linux-next merge of the BRANCH tree got $conf in:
40
41 $files
42 between commit:
43
44 $(printf '  %s\n' "${hc[@]}")
45
46 from the FIXME tree and commit:
47
48    ("")
49
50 from the BRANCH tree.
51
52 I fixed it up (see below) and can carry the fix as necessary. This
53 is now fixed as far as linux-next is concerned, but any non trivial
54 conflicts should be mentioned to your upstream maintainer when your tree
55 is submitted for merging.  You may also want to consider cooperating
56 with the maintainer of the conflicting tree to minimise any particularly
57 complex conflicts.
58 EOF
59
60 exit 0