What's cooking (2024/05 #03)
[git.git] / Dothem
blob6598da676b618111bbd1c1c26e4cf91cc3f7281f
1 #!/bin/sh
3 NWD=contrib/workdir/git-new-workdir
4 MASTER=master
6 inst_prefix=$(
7 IFS=:
8 for p in $PATH
9 do
10 probed=${p%/git-active/bin}
11 if test "$probed" != "$p"
12 then
13 echo "$probed"
14 exit
16 done
17 echo $HOME
20 force= with_dash= test_long= M= install= doc= notest= bootstrap= branches= jobs=
21 scratch= noprove= memtrash=--memtrash with_cocci= san= clean=
22 while case "$1" in
23 --pedantic | --locale=* | --loose) M="$M $1" ;;
24 --force) force=$1 ;;
25 --dash) with_dash=y ;;
26 --clean) clean=y ;;
27 --cocci) with_cocci=y ;;
28 --no-cocci) with_cocci= ;;
29 --long) test_long=--long ;;
30 --noinstall) install=noinstall ;;
31 --nodoc) doc=no ;;
32 --asciidoc) doc=asciidoc ;;
33 --asciidoctor) doc=ascidoctor ;;
34 --notest) notest=y ;;
35 --nomemtrash) memtrash= ;;
36 --memtrash) memtrash=--memtrash ;;
37 --test=*) test="$1" ;;
38 --scratch) scratch=y ;;
39 --bootstrap) bootstrap=y ;;
40 --base=*) BUILDBASE=${1#*=} ;;
41 --branches=*) branches=${1#*=} ;;
42 --noprove) noprove=$1 ;;
43 --san) san=t ;;
44 -j*) jobs=$1 ;;
45 --) shift; break ;;
46 -*) echo >&2 "Unknown option: $1"; exit 1 ;;
47 *) break ;;
48 esac
50 shift
51 done
53 if test -n "$doc"
54 then
55 : ;# happy with whatever specified
56 elif sh -c 'asciidoc --version >/dev/null 2>&1'
57 then
58 doc=asciidoc
59 elif sh -c 'asciidoctor --version >/dev/null 2>&1'
60 then
61 doc=asciidoctor
62 else
63 doc=no
66 if test "$doc" = asciidoctor
67 then
68 USE_ASCIIDOCTOR=YesPlease
69 else
70 USE_ASCIIDOCTOR=
73 GIT_TEST_CHAIN_LINT=1
74 export GIT_TEST_CHAIN_LINT
76 GIT_PROVE_OPTS="${GIT_PROVE_OPTS:+$GIT_PROVE_OPTS }--state=slow,save"
77 export GIT_PROVE_OPTS
79 test -f /bin/dash || with_dash=
80 if test -z "$BUILDBASE"
81 then
82 if test -d "$inst_prefix/buildfarm"
83 then
84 BUILDBASE="$inst_prefix/buildfarm"
85 elif test -d "../buildfarm"
86 then
87 BUILDBASE=../buildfarm
88 else
89 echo >&2 "Buildbase unknown"
90 exit 1
93 test -n "$branches" || branches="next $MASTER maint jch seen"
94 test -n "$jobs" || jobs=-j2
96 find_installed () {
97 branch=$1
98 test -f "$inst_prefix/git-$branch/bin/git" &&
99 installed=$($inst_prefix/git-$branch/bin/git version) &&
100 if version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)$')
101 then
103 elif version=v$(expr "$installed" : \
104 'git version \(.*\)\.rc[0-9]*$')
105 then
106 version="$version"-$(expr "$installed" : \
107 'git version .*\.\(rc[0-9]*\)$')
108 else
109 version=v$(expr "$installed" : 'git version \(.*\)')
110 fi &&
111 git rev-parse --verify "$version^0" 2>/dev/null
114 installed_source_trees=" "
115 for branch in $branches
117 if v=$(find_installed $branch) &&
118 test -n "$v" &&
119 v=$(git rev-parse --verify "$v^{tree}" 2>/dev/null)
120 then
121 installed_source_trees="$installed_source_trees$v "
123 done
125 for branch in $branches
127 echo "** $branch **"
128 revision=$(git show-ref -s --verify "refs/heads/$branch") || {
129 echo "** No $branch"
130 continue
133 if test ! -d "$BUILDBASE/$branch"
134 then
135 if test -z "$bootstrap"
136 then
137 echo "** No $BUILDBASE/$branch"
138 continue
140 "$NWD" . "$BUILDBASE/$branch" $branch &&
141 ln -s "$(pwd)/Meta" "$BUILDBASE/$branch/Meta" || {
142 echo "** Failed to bootstrap $BUILDBASE/$branch"
143 continue
147 private=$(git rev-parse -q --verify private-$branch 2>/dev/null)
148 case $? in 0|1) ;; *) exit $? ;; esac
150 version=$(find_installed $branch)
151 if test "z$version" = "z$revision"
152 then
153 echo "* up-to-date version is already installed from $branch"
154 test -n "$force" || continue
157 vtree=$(git rev-parse --verify "$version^{tree}")
158 rtree=$(git rev-parse --verify "$revision^{tree}")
160 skip_test=$notest
161 case "$doc" in no) skip_doc=1 ;; *) skip_doc= ;; esac
162 case "$force" in
166 for xtree in $installed_source_trees $vtree
168 if test "z$xtree" = "z$rtree" ||
169 git diff --quiet "$xtree" "$rtree" -- . \
170 ':!GIT-VERSION-GEN' \
171 ':!RelNotes' \
172 ':!Documentation/'
173 then
174 skip_test=1
175 break
177 done
179 dvtree=$(git rev-parse --verify "$version:Documentation/")
180 drtree=$(git rev-parse --verify "$revision:Documentation/")
181 if test "z$dvtree" = "z$drtree"
182 then
183 skip_doc=1
186 esac
188 case "$skip_test" in
189 ?*) dotest= ;;
190 '') dotest=test ;;
191 esac
193 cd "$BUILDBASE/$branch"
194 git reset --hard &&
196 case "$scratch$clean" in
199 *y*)
200 saveMeta=$(readlink Meta)
201 Meta/Make distclean
202 git clean -f -x -d
203 ln -s "$saveMeta" Meta
205 esac &&
207 case "$(git symbolic-ref HEAD)" in
208 "refs/heads/$branch")
209 : ;;
211 git checkout "$branch" &&
212 git reset --hard || exit
213 esac &&
215 case "$clean" in
216 y) exit 0 ;;
217 esac &&
219 case "$private" in
223 git merge --squash --no-commit "$private" || {
224 echo >&2 "** Cannot apply private edition changes"
225 git reset --hard
228 esac &&
230 save=$(git rev-parse HEAD) &&
232 if test -n "$with_cocci"
233 then
234 Meta/Make $M $jobs -- coccicheck
235 fi &&
237 Meta/Make $M $jobs -- NO_REGEX=NoThanks \
238 SPARSE_FLAGS=-Wsparse-error sparse &&
239 rm -f compat/regex/regex.o &&
240 Meta/Make $M $jobs -- hdr-check &&
242 case "$dotest,$san" in
245 test,)
246 Meta/Make $M $noprove ${test+"$test"} $jobs $test_long $memtrash \
247 -- ${with_dash:+SHELL_PATH=/bin/dash} "$@" $dotest
249 *,t)
250 SANITIZE=address,undefined Meta/Make $M $jobs test &&
251 Meta/Make >/dev/null distclean
253 esac &&
256 test -n "$skip_doc" ||
257 if test "$save" = "$(git rev-parse HEAD)"
258 then
259 Meta/Make $M $jobs -- check-docs &&
260 Meta/Make $M $jobs -- $USE_ASCIIDOCTOR doc &&
261 Meta/Make $M -- install-man install-html
262 else
263 echo >&2 "Head moved--not installing docs"
265 } &&
268 test z$install = znoinstall ||
269 if test "$save" = "$(git rev-parse HEAD)"
270 then
271 Meta/Make $M -- ${with_dash:+SHELL_PATH=/bin/dash} "$@" install
272 else
273 echo >&2 "Head moved--not installing"
275 } || exit $?
277 git reset --hard
278 ) </dev/null || exit $?
280 installed_source_trees="$installed_source_trees$rtree "
281 done