]> git.ozlabs.org Git - next-scripts/blob - merge_msg
update to_build_host a bit
[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 mc=()
15 cc=()
16 cformat='%(trailers:only=no,valueonly,unfold,key=signed-off-by)%aN <%aE>%n%cN <%cE>'
17
18 read -r -a head_commits -p 'HEAD commit(s): '
19 for c in "${head_commits[@]}"; do
20         if ! git rev-parse --verify "$c" >/dev/null; then
21                 printf 'Unknown commit %s\n' "$c"
22                 exit 1
23         fi
24         hc+=( "$(git log -1 --format='%h ("%s")' "$c")" )
25         readarray -t -O "${#cc[@]}" cc < <(git log -1 --format="$cformat" "$c" | sort -u)
26 done
27 hcs=''
28 if [ "${#hc[@]}" -gt 1 ]; then
29         hcs='s'
30 fi
31
32 read -r -a head_branches -p 'HEAD branch(es): '
33
34 hb=( "${head_branches[@]/%/,}" )
35 hb[-1]=${hb[-1]%,}
36 if [ "${#hb[@]}" -gt 2 ]; then
37         hb[-2]=${hb[-2]/%,/ and}
38 fi
39 hbs=''
40 if [ "${#hb[@]}" -gt 1 ]; then
41         hbs='s'
42 fi
43
44 printf -v subject 'manual merge of the BRANCH tree with the %s tree%s' \
45         "${hb[*]}" "$hbs"
46
47 read -r -a merge_commits -p 'MERGE_HEAD commit(s): '
48 for c in "${merge_commits[@]}"; do
49         if ! git rev-parse --verify "$c" >/dev/null; then
50                 printf 'Unknown commit %s\n' "$c"
51                 exit 1
52         fi
53         mc+=( "$(git log -1 --format='%h ("%s")' "$c")" )
54         readarray -t -O "${#cc[@]}" cc < <(git log -1 --format="$cformat" "$c" | sort -u)
55 done
56 mcs=''
57 if [ "${#mc[@]}" -gt 1 ]; then
58         mcs='s'
59 fi
60
61 printf -v files '  %s\n' "$@"
62 conf='a conflict'
63 if [ "$#" -gt 1 ]; then
64         conf='conflicts'
65 fi
66
67 "$tools_dir/message_helper" "${branch[@]}" "$subject" "${cc[@]}" <<EOF
68 FIXME: Add owner of second tree to To:
69        Add author(s)/SOB of conflicting commits.
70
71 Today's linux-next merge of the BRANCH tree got $conf in:
72
73 $files
74 between commit$hcs:
75
76 $(printf '  %s\n' "${hc[@]}")
77
78 from the ${hb[*]} tree$hbs and commit$mcs:
79
80 $(printf '  %s\n' "${mc[@]}")
81
82 from the BRANCH tree.
83
84 I fixed it up (see below) and can carry the fix as necessary. This
85 is now fixed as far as linux-next is concerned, but any non trivial
86 conflicts should be mentioned to your upstream maintainer when your tree
87 is submitted for merging.  You may also want to consider cooperating
88 with the maintainer of the conflicting tree to minimise any particularly
89 complex conflicts.
90 EOF
91
92 exit 0