]> git.xonotic.org Git - xonotic/xonotic.git/blob - all
40ba27bed6211c8a777a36358d4c24353859678a
[xonotic/xonotic.git] / all
1 #!/bin/sh
2 # vim: filetype=zsh
3
4 set -e
5
6 # I use this in EVERY shell script ;)
7 LF="
8 "
9
10 d00=`pwd`
11 while ! [ -f ./all ]; do
12         if [ x"`pwd`" = x"/" ]; then
13                 echo "Cannot find myself."
14                 echo "Please run this script with the working directory inside a Xonotic checkout."
15                 exit 1
16         fi
17         cd ..
18 done
19 d0=`pwd`
20 SELF="$d0/all"
21
22 # If we are on WINDOWS:
23 case "$0" in
24         all|*/all)
25                 case "`uname`" in
26                         MINGW*|Win*)
27                                 # Windows hates users. So this script has to copy itself elsewhere first...
28                                 tname=
29                                 cp "$SELF" ../all.xonotic.sh
30                                 export WE_HATE_OUR_USERS=1
31                                 exec ../all.xonotic.sh "$@"
32                                 ;;
33                 esac
34                 ;;
35 esac
36
37 msg()
38 {
39         echo "\e[1m$*\e[m"
40 }
41
42 checksum()
43 {
44         if [ -x /usr/bin/md5sum ]; then
45                 /usr/bin/md5sum "$@"
46         elif [ -x /bin/md5sum ]; then
47                 /bin/md5sum "$@"
48         elif [ -x /usr/bin/cksum ]; then
49                 /usr/bin/cksum "$@"
50         else
51                 echo "NOCHECKSUM"
52         fi
53 }
54
55 self=`checksum "$SELF"`
56 checkself()
57 {
58         self_new=`checksum "$SELF"`
59         if [ x"$self" != x"$self_new" ]; then
60                 msg "./all has changed."
61                 if [ -z "$XONOTIC_FORBID_RERUN_ALL" ]; then
62                         msg "Rerunning the requested operation to make sure."
63                         export XONOTIC_FORBID_RERUN_ALL=1
64                         exec "$SELF" "$@"
65                 else
66                         msg "Please try $SELF update, and then retry your requested operation."
67                         exit 1
68                 fi
69         fi
70         return 0
71 }
72
73 verbose()
74 {
75         msg "+ $*"
76         "$@"
77 }
78
79 visible_repo_name()
80 {
81         case "$1" in
82                 .)
83                         echo "the root directory"
84                         ;;
85                 *)
86                         echo "\"$1\""
87                         ;;
88         esac
89 }
90
91 check_mergeconflict()
92 {
93         if git ls-files -u | grep ' 1   '; then
94                 echo
95                 echo "MERGE CONFLICT."
96                 echo "change into the \"$1\" project directory, and then:"
97                 echo "- edit the files mentioned above with your favorite editor,"
98                 echo "  and fix the conflicts (marked with <<<<<<< blocks)"
99                 echo "- for binary files, you can select the files using"
100                 echo "  git checkout --ours or git checkout --theirs"
101                 echo "- when done with a file, 'git add' the file"
102                 echo "- when done, 'git commit'"
103                 echo
104                 exit 1
105         fi
106 }
107
108 yesno()
109 {
110         yesno=
111         while [ x"$yesno" != x"y" -a x"$yesno" != x"n" ]; do
112                 eval "$2"
113                 echo "$1"
114                 IFS= read -r yesno
115         done
116         [ x"$yesno" = x"y" ]
117 }
118
119 enter()
120 {
121         $2 cd "$1"
122         check_mergeconflict "$1"
123 }
124
125 repos_urls="
126 .                             |                                                   | master      |
127 data/xonotic-data.pk3dir      |                                                   | master      |
128 data/xonotic-maps.pk3dir      |                                                   | master      |
129 data/xonotic-music.pk3dir     |                                                   | master      |
130 data/xonotic-nexcompat.pk3dir |                                                   | master      |
131 mediasource                   |                                                   | master      |
132 darkplaces                    |                                                   | div0-stable | svn
133 fteqcc                        | git://github.com/Blub/qclib.git                   | master      |
134 div0-gittools                 | git://git.icculus.org/divverent/div0-gittools.git | master      |
135 netradiant                    |                                                   | master      |
136 "
137 # todo: in darkplaces, change repobranch to div0-stable
138
139 repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
140
141 base=`git config remote.origin.url`
142 case "$base" in
143         */xonotic.git)
144                 base=${base%xonotic.git}
145                 ;;
146         *)
147                 echo "The main repo is not xonotic.git, what have you done?"
148                 exit 1
149                 ;;
150 esac
151
152 repourl()
153 {
154         t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
155         if [ -n "$t" ]; then
156                 case "$t" in
157                         *://*)
158                                 echo "$t"
159                                 ;;
160                         *)
161                                 echo "$base$t"
162                                 ;;
163                 esac
164         else
165                 if [ x"$1" = x"." ]; then
166                         echo "$base""xonotic.git"
167                 else
168                         echo "$base${1##*/}.git"
169                 fi
170         fi
171 }
172
173 repobranch()
174 {
175         t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
176         if [ -n "$t" ]; then
177                 echo "$t"
178         else
179                 echo "master"
180         fi
181 }
182
183 repoflags()
184 {
185         echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 4 | tr -d ' '
186         echo "$t"
187 }
188
189 repos=`for d in $repos; do
190         p="${d%dir}"
191         if [ x"$p" = x"$d" ] || [ -d "$d" ] || ! [ -f "$p" ]; then
192                 echo "$d"
193         fi
194 done`
195
196 if [ "$#" = 0 ]; then
197         set -- help
198 fi
199 cmd=$1
200 shift
201
202 case "$cmd" in
203         update|pull)
204                 allow_pull=true
205                 if [ x"$1" = x"-N" ]; then
206                         allow_pull=false
207                 fi
208                 for d in $repos; do
209                         url=`repourl "$d"`
210                         branch=`repobranch "$d"`
211                         if [ -d "$d0/$d" ]; then
212                                 if $allow_pull; then
213                                         enter "$d0/$d" verbose
214                                         verbose git config remote.origin.url "$url"
215                                         verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
216
217                                         r=`git symbolic-ref HEAD`
218                                         r=${r#refs/heads/}
219                                         if git config branch.$r.remote >/dev/null 2>&1; then
220                                                 if ! verbose git pull; then
221                                                         check_mergeconflict "$d"
222                                                         echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
223                                                         read -r DUMMY
224                                                 fi
225                                         fi
226
227                                         cd "$d00"
228                                         checkself "$cmd" "$@"
229                                         cd "$d0/$d"
230                                         verbose git remote prune origin
231                                         cd "$d0"
232                                 fi
233                         else
234                                 verbose git clone "$url" "$d0/$d"
235                                 enter "$d0/$d" verbose
236                                 verbose git checkout "$branch"
237                                 cd "$d0"
238                         fi
239                 done
240                 ;;
241         checkout|switch)
242                 remote=$1
243                 branch=$2
244                 if [ -z "$branch" ]; then
245                         branch=$remote
246                         remote=origin
247                 fi
248                 exists=false
249                 for d in $repos; do
250                         enter "$d0/$d" verbose
251                         if [ -z "$branch" ]; then
252                                 b=`repobranch "$d"`
253                         else
254                                 b=$branch
255                         fi
256                         if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
257                                 exists=true
258                                 verbose git checkout "$b"
259                         elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
260                                 exists=true
261                                 verbose git checkout --track -b "$b" "$remote/$b"
262                         else
263                                 verbose git checkout "`repobranch "$d"`"
264                         fi
265                         cd "$d00"
266                         checkself "$cmd" "$@"
267                         cd "$d0"
268                 done
269                 if ! $exists; then
270                         echo "The requested branch was not found in any repository."
271                 fi
272                 exec "$SELF" branch
273                 ;;
274         branch)
275                 remote=$1
276                 branch=$2
277                 srcbranch=$3
278                 if [ -z "$branch" ]; then
279                         branch=$remote
280                         remote=origin
281                 fi
282                 if [ -z "$branch" ]; then
283                         for d in $repos; do
284                                 enter "$d0/$d"
285                                 r=`git symbolic-ref HEAD`
286                                 r=${r#refs/heads/}
287                                 echo "$d is at $r"
288                                 cd "$d0"
289                         done
290                 else
291                         for d in $repos; do
292                                 dv=`visible_repo_name "$d"`
293                                 enter "$d0/$d" verbose
294                                 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
295                                         echo "Already having this branch in $dv."
296                                 else
297                                         if yesno "Branch in $dv?"; then
298                                                 if [ -n "$srcbranch" ]; then
299                                                         b=$srcbranch
300                                                 else
301                                                         b=origin/"`repobranch "$d"`"
302                                                         verbose git fetch origin || true
303                                                 fi
304                                                 # TODO do this without pushing
305                                                 verbose git checkout -b "$branch" "$b"
306                                                 verbose git config "branch.$branch.remote" "$remote"
307                                                 verbose git config "branch.$branch.merge" "refs/heads/$branch"
308                                         fi
309                                 fi
310                                 cd "$d0"
311                         done
312                         "$SELF" branch
313                 fi
314                 ;;
315         branches)
316                 for d in $repos; do
317                         enter "$d0/$d"
318                         echo "In $d:"
319                         git branch -a -v -v | cut -c 3- | while read -r BRANCH REV UPSTREAM TEXT; do
320                                 case "$UPSTREAM" in
321                                         \[*)
322                                                 UPSTREAM=${UPSTREAM#\[}
323                                                 UPSTREAM=${UPSTREAM%\]}
324                                                 UPSTREAM=${UPSTREAM%:*}
325                                                 ;;
326                                         *)
327                                                 TEXT="$UPSTREAM $TEXT"
328                                                 UPSTREAM=
329                                                 ;;
330                                 esac
331                                 if [ x"$REV" = x"->" ]; then
332                                         continue
333                                 fi
334                                 BRANCH=${BRANCH#remotes/}
335                                 echo -n "  $BRANCH"
336                                 if [ -n "$UPSTREAM" ]; then
337                                         echo -n " (tracking $UPSTREAM)"
338                                 fi
339                                 #echo " $TEXT"
340                                 echo
341                         done
342                 done
343                 ;;
344         branches_short)
345                 for d in $repos; do
346                         cd "$d0/$d" # am in a pipe, shouldn't use enter
347                         git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
348                         cd "$d0"
349                 done | {
350                         branches_list=
351                         # branches_repos_*=
352                         while read -r d BRANCH REV UPSTREAM TEXT; do
353                                 case "$UPSTREAM" in
354                                         \[*)
355                                                 UPSTREAM=${UPSTREAM#\[}
356                                                 UPSTREAM=${UPSTREAM%\]}
357                                                 UPSTREAM=${UPSTREAM%:*}
358                                                 ;;
359                                         *)
360                                                 TEXT="$UPSTREAM $TEXT"
361                                                 UPSTREAM=
362                                                 ;;
363                                 esac
364                                 if [ x"$REV" = x"->" ]; then
365                                         continue
366                                 fi
367                                 BRANCH=${BRANCH#remotes/}
368                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
369                                 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
370                                 eval "r=\$branches_repos_$ID"
371                                 r="$r $d:$UPSTREAM"
372                                 eval "branches_repos_$ID=\$r"
373                         done
374                         echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
375                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
376                                 eval "r=\$branches_repos_$ID"
377                                 echo "$BRANCH: $r"
378                         done
379                 }
380                 ;;
381         merge)
382                 for d in $repos; do
383                         dv=`visible_repo_name "$d"`
384                         enter "$d0/$d" verbose
385                         r=`git symbolic-ref HEAD`
386                         r=${r#refs/heads/}
387                         if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
388                                 # we have uncommitted changes
389                                 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
390                                         if ! verbose git merge origin/"`repobranch "$d"`"; then
391                                                 check_mergeconflict "$d"
392                                                 exit 1 # this should ALWAYS be fatal
393                                         fi
394                                 fi
395                         fi
396                         cd "$d0"
397                 done
398                 ;;
399         push|commit)
400                 submit=$1
401                 for d in $repos; do
402                         dv=`visible_repo_name "$d"`
403                         enter "$d0/$d" verbose
404                         r=`git symbolic-ref HEAD`
405                         r=${r#refs/heads/}
406                         if git diff HEAD | grep .; then
407                                 # we have uncommitted changes
408                                 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?"; then
409                                         verbose git commit -a
410                                 fi
411                         fi
412                         rem=`git config "branch.$r.remote" || echo origin`
413                         bra=`git config "branch.$r.merge" || echo "$r"`
414                         upstream="$rem/$bra"
415                         if ! [ git rev-parse "$upstream" ]; then
416                                 upstream="`repobranch "$d"`"
417                         fi
418                         if git log "$upstream".."$r" | grep .; then
419                                 if yesno "Push \"$r\" in $dv?"; then
420                                         verbose git push "$rem" HEAD
421                                 fi
422                         fi
423                         if [ x"$submit" = x"-s" ]; then
424                                 case "$r" in
425                                         */*)
426                                                 verbose git push "$rem" HEAD:"${bra%%/*}/finished/${bra#*/}"
427                                                 ;;
428                                 esac
429                         fi
430                         cd "$d0"
431                 done
432                 ;;
433         compile)
434                 if [ -n "$WE_HATE_OUR_USERS" ]; then
435                         TARGETS="sv-debug cl-debug"
436                 else
437                         TARGETS="sv-debug cl-debug sdl-debug"
438                 fi
439                 case "$1" in
440                         -c)
441                                 clean=true
442                                 shift
443                                 ;;
444                         *)
445                                 clean=false
446                                 ;;
447                 esac
448                 case "$1" in
449                         sdl)
450                                 TARGETS="sdl-debug"
451                                 shift
452                                 ;;
453                         glx|agl|wgl)
454                                 TARGETS="cl-debug"
455                                 shift
456                                 ;;
457                         dedicated)
458                                 TARGETS="sv-debug"
459                                 shift
460                                 ;;
461                 esac
462                 if [ -z "$MAKEFLAGS" ]; then
463                         if [ -f /proc/cpuinfo ]; then
464                                 ncpus=$((`grep -c '^processor   :' /proc/cpuinfo`+0))
465                                 if [ $ncpus -gt 1 ]; then
466                                         MAKEFLAGS=-j$ncpus
467                                 fi
468                         fi
469                         case "`uname`" in
470                                 Linux|*BSD)
471                                         MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
472                                         ;;
473                         esac
474                         if [ -n "$WE_HATE_OUR_USERS" ]; then
475                                 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
476                         fi
477                 fi
478                 enter "$d0/fteqcc" verbose
479                 if $clean; then
480                         verbose make $MAKEFLAGS clean
481                 fi
482                 verbose make $MAKEFLAGS
483                 enter "$d0/data/xonotic-data.pk3dir" verbose
484                 if $clean; then
485                         verbose make $MAKEFLAGS clean
486                 fi
487                 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
488                 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
489                 enter "$d0/darkplaces" verbose
490                 if $clean; then
491                         verbose make $MAKEFLAGS clean
492                 fi
493                 for T in $TARGETS; do
494                         verbose make $MAKEFLAGS "$@" "$T"
495                 done
496                 ;;
497         run)
498                 if [ -n "$WE_HATE_OUR_USERS" ]; then
499                         client=
500                         export PATH="$d0/misc/buildfiles/w32:$PATH"
501                 elif [ x"`uname`" = x"Darwin" ]; then
502                         export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Nexuiz.app/Contents/MacOS"
503                         client=-sdl
504                 else
505                         client=-sdl
506                 fi
507                 case "$1" in
508                         sdl|glx|agl|dedicated)
509                                 client=-$1
510                                 shift
511                                 ;;
512                         wgl)
513                                 client=
514                                 shift
515                                 ;;
516                 esac
517                 if ! [ -x "darkplaces/darkplaces$client" ]; then
518                         if [ -x "darkplaces/darkplaces$client.exe" ]; then
519                                 client=$client.exe
520                         else
521                                 echo "Client darkplaces/darkplaces$client not found, aborting"
522                                 exit 1
523                         fi
524                 fi
525                 set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
526
527                 # if pulseaudio is running: USE IT
528                 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ]; then
529                         if ps -C pulseaudio >/dev/null; then
530                                 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
531                                         export SDL_AUDIODRIVER=pulse
532                                 fi
533                         fi
534                 fi
535
536                 if [ -n "$USE_GDB" ]; then
537                         set -- gdb --args "$@"
538                 fi
539                 "$@"
540                 ;;
541         each|foreach)
542                 for d in $repos; do
543                         if verbose cd "$d0/$d"; then
544                                 verbose "$@"
545                                 cd "$d0"
546                         fi
547                 done
548                 ;;
549         save-patches)
550                 outfile=$1
551                 patchdir=`mktemp -d -t save-patches.XXXXXX`
552                 for d in $repos; do
553                         enter "$d0/$d" verbose
554                         git branch -v -v | cut -c 3- | {
555                                 i=0
556                                 while read -r BRANCH REV UPSTREAM TEXT; do
557                                         case "$UPSTREAM" in
558                                                 \[*)
559                                                         UPSTREAM=${UPSTREAM#\[}
560                                                         UPSTREAM=${UPSTREAM%\]}
561                                                         UPSTREAM=${UPSTREAM%:*}
562                                                         TRACK=true
563                                                         ;;
564                                                 *)
565                                                         UPSTREAM=origin/"`repobranch "$d"`"
566                                                         TRACK=false
567                                                         ;;
568                                         esac
569                                         if [ x"$REV" = x"->" ]; then
570                                                 continue
571                                         fi
572                                         if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
573                                                 echo "$d" > "$patchdir/$i/info.txt"
574                                                 echo "$BRANCH" >> "$patchdir/$i/info.txt"
575                                                 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
576                                                 echo "$TRACK" >> "$patchdir/$i/info.txt"
577                                                 i=$(($i+1))
578                                         else
579                                                 rm -rf "$patchdir/$i"
580                                         fi
581                                 done
582                         }
583                 done
584                 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
585                 rm -rf "$patchdir"
586                 ;;
587         restore-patches)
588                 infile=$1
589                 patchdir=`mktemp -d -t restore-patches.XXXXXX`
590                 ( cd "$patchdir" && tar xvzf - ) < "$infile"
591                 # detach the head
592                 for P in "$patchdir"/*/info.txt; do
593                         D=${P%/info.txt}
594                         exec 3<"$P"
595                         read -r d <&3
596                         read -r BRANCH <&3
597                         read -r UPSTREAM <&3
598                         read -r TRACK <&3
599                         verbose git checkout HEAD^0
600                         verbose git branch -D "$BRANCH"
601                         if [ x"$TRACK" = x"true" ]; then
602                                 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
603                         else
604                                 verbose git branch -b "$BRANCH" "$UPSTREAM"
605                         fi
606                         verbose git am "$D"
607                 done
608                 rm -rf "$patchdir"
609                 ;;
610         admin-merge)
611                 if [ "$#" = 1 ]; then
612                         set -- "${1%%/*}" "${1#*/}"
613                 fi
614                 for d in $repos; do
615                         enter "$d0/$d" verbose
616                         git rev-parse "$1/$2" || continue
617                         # 1. review
618                         {
619                                 git log HEAD.."$1/$2"
620                                 git diff HEAD..."$1/$2"
621                         } | less
622                         if yesno "Merge \"$1/$2\" into `git symbolic-ref HEAD` of $d?"; then
623                                 git merge "$1/$2"
624                                 if "$SELF" compile && yesno "Still merge \"$1/$2\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
625                                         git push origin HEAD
626                                         git push "$1" :"$2"
627                                 else
628                                         git reset --hard HEAD@{1}
629                                 fi
630                         fi
631                 done
632                 ;;
633         admin-merge-2)
634                 t=`mktemp`
635                 report=""
636                 reportecho()
637                 {
638                         report=$report"$*$LF"
639                         echo "$*"
640                 }
641                 reportecho4()
642                 {
643                         report=$report"    $*$LF"
644                         echo "    $*"
645                 }
646                 reportdo4()
647                 {
648                         o=`"$@" | sed 's/^/    /' || true`
649                         reportecho "$o"
650                 }
651                 for d in $repos; do
652                         enter "$d0/$d" verbose
653                         base="`repobranch "$d"`"
654                         reportecho "In $d:"
655                         for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
656                                 case "${ref#refs/remotes/origin/}" in
657                                         "$base")
658                                                 continue
659                                                 ;;
660                                         HEAD|master)
661                                                 continue
662                                                 ;;
663                                 esac
664                                 reportecho "  Branch $ref:"
665                                 note=`git notes --ref "refs/notes/admin-merge" show "$ref" 2>/dev/null || true`
666                                 if [ -n "$note" ]; then
667                                         reportdo4 echo "$note"
668                                         reportecho4 "--> not merging, already had this one rejected before"
669                                 elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ git log --color "$base".."$ref"; git diff --color --find-copies-harder --ignore-space-change "$base"..."$ref"; } | less -r'; then
670                                         git checkout "$base"
671                                         org=`git rev-parse HEAD`
672                                         if ! git merge "$ref" 2>&1 | tee "$t"; then
673                                                 git reset --hard "$org"
674                                                 git notes --ref "refs/notes/admin-merge" add -m "Merge failed:$LF`cat "$t"`" "$ref"
675                                                 reportdo4 cat "$t"
676                                                 reportecho4 "--> merge failed"
677                                         elif ! "$SELF" compile 2>&1 | tee "$t"; then
678                                                 git reset --hard "$org"
679                                                 git notes --ref "refs/notes/admin-merge" add -m "Compile failed:$LF`cat "$t"`" "$ref"
680                                                 reportdo4 cat "$t"
681                                                 reportecho4 "--> compile failed"
682                                         elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
683                                                 git reset --hard "$org"
684                                                 git notes --ref "refs/notes/admin-merge" add "$ref"
685                                                 note=`git notes --ref "refs/notes/admin-merge" show "$ref" 2>/dev/null || true`
686                                                 reportdo4 echo "$note"
687                                                 reportecho4 "--> test failed"
688                                         else
689                                                 case ",`repoflags "$d"`," in
690                                                         *,svn,*)
691                                                                 # we do quite a mess here... luckily we know $org
692                                                                 git pull # svn needs to be current
693                                                                 git rebase -i --onto master "$org"
694                                                                 git svn dcommit --add-author-from
695                                                                 git reset --hard "$org"
696                                                                 ;;
697                                                         *)
698                                                                 git push origin HEAD
699                                                                 ;;
700                                                 esac
701                                                 reportecho4 "--> MERGED"
702                                                 if yesno "Delete original branch \"$ref\"?"; then
703                                                         git push origin :"${ref#refs/remotes/origin/}"
704                                                         reportecho4 "--> branch deleted"
705                                                 fi
706                                         fi
707                                 else
708                                         git notes --ref "refs/notes/admin-merge" add "$ref"
709                                         note=`git notes --ref "refs/notes/admin-merge" show "$ref" 2>/dev/null || true`
710                                         if [ -n "$note" ]; then
711                                                 reportdo4 echo "$note"
712                                                 reportecho4 "--> rejected"
713                                         else
714                                                 reportecho4 "--> postponed"
715                                         fi
716                                 fi
717                                 reportecho ""
718                         done
719                         reportecho ""
720                 done
721                 rm -f "$t"
722                 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
723                 ;;
724         *)
725                 echo "Usage:"
726                 echo "  $SELF pull"
727                 echo "  $SELF merge"
728                 echo "  $SELF push [-s]"
729                 echo "  $SELF branches"
730                 echo "  $SELF branch [<remote>] <branchname>"
731                 echo "  $SELF branch <remote> <branchname> <srcbranchname>"
732                 echo "  $SELF checkout [<remote>] <branchname>"
733                 echo "  $SELF compile [-c] [<client>] <options>"
734                 echo "  $SELF run [<client>] <options>"
735                 echo "  $SELF each <command>"
736                 ;;
737 esac