Meta/TopicCheck: allow merging on a base before testing

Junio C Hamano committed May 30, 2026 at 09:49 UTC d0bf7fefe88af9fb153e4dd3bc919686dcda6287
1 file changed +39 -14
TopicCheck
+39 -14
@@ -1,15 +1,21 @@
1 #!/bin/sh
2
3 +tmp=/var/tmp/TopicCheck.$$
4 +trap 'rm -fr "$tmp" "$tmp."*' 0 1 2 3 15
5 +
6 usage () {
4 - echo >&2 "usage: $0 [--stdin | <topics>...]"
7 + echo >&2 "usage: $0 [--with <base>] [--stdin | <topics>...]"
8 }
9
7 -stdin=
10 +stdin= with=
11 while case "$1" in -*) ;; *) break; esac
12 do
13 case "$1" in
14 --stdin)
15 stdin=stdin ;;
16 + --with)
17 + with="${2?<base>}"
18 + shift ;;
19 *)
20 usage
21 exit 1 ;;
@@ -36,13 +42,25 @@ mkdir -p "$logbase"
42 exec 3>&2
43
44 onetopic () {
39 - topic="$1"
45 + topic="$1" rest="$2"
46 + label=${rest:-$topic}
47 log="$logbase/$(echo "$topic" | tr '/' '-')"
48 exec >"$log" 2>&1
42 - git reset --hard "$topic"
49 +
50 + if test -n "$with"
51 + then
52 + git reset --hard "$with" &&
53 + git merge --quiet "$topic"
54 + else
55 + git reset --hard "$topic"
56 + fi || {
57 + echo >&2 "cannot prepare $label"
58 + return
59 + }
60 +
61 failed=
62
45 - section "$topic - leaks" &&
63 + section "$label - leaks" &&
64 (
65 export SANITIZE=leak GIT_TEST_PASSING_SANITIZE_LEAK=true &&
66 Meta/Make -j32 CC=clang test
@@ -51,7 +69,7 @@ onetopic () {
69 exit $st
70 ) || failed="leaks"
71
54 - section "$topic - sha256" &&
72 + section "$label - sha256" &&
73 (
74 export GIT_TEST_DEFAULT_HASH=sha256 &&
75 Meta/Make -j32 test
@@ -60,16 +78,16 @@ onetopic () {
78 exit $st
79 ) || failed="$failed${failed:+" "}sha256"
80
63 - section "$topic - test" &&
81 + section "$label - test" &&
82 (
65 - : export GIT_TEST_LONG=YesPlease &&
83 + export GIT_TEST_LONG=YesPlease &&
84 Meta/Make -j32 test
85 st=$?
86 Meta/Make >/dev/null 2>&1 distclean
87 exit $st
88 ) || failed="$failed${failed:+" "}test"
89
72 - section "$topic - breaking" &&
90 + section "$label - breaking" &&
91 (
92 Meta/Make $jobs WITH_BREAKING_CHANGES=YesPlease $T test
93 st=$?
@@ -81,8 +99,8 @@ onetopic () {
99 then
100 rm -f "$log"
101 else
84 - echo >&3 "failed ($failed) $topic"
85 - echo >&2 "failed ($failed) $topic"
102 + echo >&3 "failed ($failed) $label"
103 + echo >&2 "failed ($failed) $label"
104 fi
105 }
106
@@ -90,11 +108,18 @@ if test "$stdin" = stdin
108 then
109 while read topic
110 do
93 - onetopic "$topic"
111 + echo $(git rev-parse "$topic") "$topic"
112 done
113 else
114 for topic
115 do
98 - onetopic "$topic"
116 + echo $(git rev-parse "$topic") "$topic"
117 done
100 -fi
118 +fi >"$tmp".lst
119 +
120 +while read oid topic
121 +do
122 + onetopic "$oid" "$topic"
123 +done <"$tmp".lst
124 +
125 +rmdir 2>/dev/null "$logbase" || :