onemerge: make sure each merge in master..seen brings in only one topic
If a topic B is built on top of a merge of topic A into master, then we should merge topic A first before topic B when preparing the integration branches. Merging topic B first would bring topic A along with it, which is generally not a good idea if we consider A and B as two separate topics.
Junio C Hamano committed
Jun 29, 2026 at 09:25 UTC
ca61a38eca70897e2db33efc913a7b682168de52
1 file changed
+34
onemerge.sh
new
+34
@@ -0,0 +1,34 @@
1
+#!/bin/sh
2
+# between master..seen, are there merges that bring in
3
+# more than one topic at a time?
4
+
5
+endpoint=${1-seen}
6
+
7
+tmp=/var/tmp/e.$$
8
+rm -f "$tmp.1" "$tmp.2" &&
9
+prev= &&
10
+trap 'rm -f "$tmp.*"' 0 || exit
11
+
12
+git rev-list --merges --first-parent master..$endpoint |
13
+while read commit
14
+do
15
+ # $tmp.1 has remaining topics after the merge we are looking at.
16
+ # $tmp.2 has remaining topics after the previous merge that is
17
+ # a descendant of the current merge.
18
+
19
+ git branch --list --no-merged "$commit" '??/*' >"$tmp.1"
20
+ if test -f "$tmp.2" && test -n "$prev"
21
+ then
22
+ cnt=$(comm -23 "$tmp.1" "$tmp.2" | wc -l)
23
+ if test $cnt != 1
24
+ then
25
+ echo Merges multiple topics
26
+ git show -s --format="* %s" "$prev"
27
+ comm -23 "$tmp.1" "$tmp.2"
28
+ exit
29
+
30
+ fi
31
+ fi
32
+ mv -f "$tmp.1" "$tmp.2"
33
+ prev=$commit
34
+done