fix two slash errors
[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                                 if [ "$branch" != "master" ]; then
237                                         verbose git checkout --track -b "$branch" origin/"$branch"
238                                 fi
239                                 cd "$d0"
240                         fi
241                 done
242                 ;;
243         checkout|switch)
244                 remote=$1
245                 branch=$2
246                 if [ -z "$branch" ]; then
247                         branch=$remote
248                         remote=origin
249                 fi
250                 exists=false
251                 for d in $repos; do
252                         enter "$d0/$d" verbose
253                         if [ -z "$branch" ]; then
254                                 b=`repobranch "$d"`
255                         else
256                                 b=$branch
257                         fi
258                         if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
259                                 exists=true
260                                 verbose git checkout "$b"
261                         elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
262                                 exists=true
263                                 verbose git checkout --track -b "$b" "$remote/$b"
264                         else
265                                 verbose git checkout "`repobranch "$d"`"
266                         fi
267                         cd "$d00"
268                         checkself "$cmd" "$@"
269                         cd "$d0"
270                 done
271                 if ! $exists; then
272                         echo "The requested branch was not found in any repository."
273                 fi
274                 exec "$SELF" branch
275                 ;;
276         branch)
277                 remote=$1
278                 branch=$2
279                 srcbranch=$3
280                 if [ -z "$branch" ]; then
281                         branch=$remote
282                         remote=origin
283                 fi
284                 if [ -z "$branch" ]; then
285                         for d in $repos; do
286                                 enter "$d0/$d"
287                                 r=`git symbolic-ref HEAD`
288                                 r=${r#refs/heads/}
289                                 echo "$d is at $r"
290                                 cd "$d0"
291                         done
292                 else
293                         for d in $repos; do
294                                 dv=`visible_repo_name "$d"`
295                                 enter "$d0/$d" verbose
296                                 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
297                                         echo "Already having this branch in $dv."
298                                 else
299                                         if yesno "Branch in $dv?"; then
300                                                 if [ -n "$srcbranch" ]; then
301                                                         b=$srcbranch
302                                                 else
303                                                         b=origin/"`repobranch "$d"`"
304                                                         verbose git fetch origin || true
305                                                 fi
306                                                 # TODO do this without pushing
307                                                 verbose git checkout -b "$branch" "$b"
308                                                 verbose git config "branch.$branch.remote" "$remote"
309                                                 verbose git config "branch.$branch.merge" "refs/heads/$branch"
310                                         fi
311                                 fi
312                                 cd "$d0"
313                         done
314                         "$SELF" branch
315                 fi
316                 ;;
317         branches)
318                 for d in $repos; do
319                         enter "$d0/$d"
320                         echo "In $d:"
321                         git branch -a -v -v | cut -c 3- | while read -r BRANCH REV UPSTREAM TEXT; do
322                                 case "$UPSTREAM" in
323                                         \[*)
324                                                 UPSTREAM=${UPSTREAM#\[}
325                                                 UPSTREAM=${UPSTREAM%\]}
326                                                 UPSTREAM=${UPSTREAM%:*}
327                                                 ;;
328                                         *)
329                                                 TEXT="$UPSTREAM $TEXT"
330                                                 UPSTREAM=
331                                                 ;;
332                                 esac
333                                 if [ x"$REV" = x"->" ]; then
334                                         continue
335                                 fi
336                                 BRANCH=${BRANCH#remotes/}
337                                 echo -n "  $BRANCH"
338                                 if [ -n "$UPSTREAM" ]; then
339                                         echo -n " (tracking $UPSTREAM)"
340                                 fi
341                                 #echo " $TEXT"
342                                 echo
343                         done
344                 done
345                 ;;
346         branches_short)
347                 for d in $repos; do
348                         cd "$d0/$d" # am in a pipe, shouldn't use enter
349                         git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
350                         cd "$d0"
351                 done | {
352                         branches_list=
353                         # branches_repos_*=
354                         while read -r d BRANCH REV UPSTREAM TEXT; do
355                                 case "$UPSTREAM" in
356                                         \[*)
357                                                 UPSTREAM=${UPSTREAM#\[}
358                                                 UPSTREAM=${UPSTREAM%\]}
359                                                 UPSTREAM=${UPSTREAM%:*}
360                                                 ;;
361                                         *)
362                                                 TEXT="$UPSTREAM $TEXT"
363                                                 UPSTREAM=
364                                                 ;;
365                                 esac
366                                 if [ x"$REV" = x"->" ]; then
367                                         continue
368                                 fi
369                                 BRANCH=${BRANCH#remotes/}
370                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
371                                 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
372                                 eval "r=\$branches_repos_$ID"
373                                 r="$r $d:$UPSTREAM"
374                                 eval "branches_repos_$ID=\$r"
375                         done
376                         echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
377                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
378                                 eval "r=\$branches_repos_$ID"
379                                 echo "$BRANCH: $r"
380                         done
381                 }
382                 ;;
383         merge)
384                 for d in $repos; do
385                         dv=`visible_repo_name "$d"`
386                         enter "$d0/$d" verbose
387                         r=`git symbolic-ref HEAD`
388                         r=${r#refs/heads/}
389                         if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
390                                 # we have uncommitted changes
391                                 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
392                                         if ! verbose git merge origin/"`repobranch "$d"`"; then
393                                                 check_mergeconflict "$d"
394                                                 exit 1 # this should ALWAYS be fatal
395                                         fi
396                                 fi
397                         fi
398                         cd "$d0"
399                 done
400                 ;;
401         push|commit)
402                 submit=$1
403                 for d in $repos; do
404                         dv=`visible_repo_name "$d"`
405                         enter "$d0/$d" verbose
406                         r=`git symbolic-ref HEAD`
407                         r=${r#refs/heads/}
408                         if git diff HEAD | grep .; then
409                                 # we have uncommitted changes
410                                 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?"; then
411                                         verbose git commit -a
412                                 fi
413                         fi
414                         rem=`git config "branch.$r.remote" || echo origin`
415                         bra=`git config "branch.$r.merge" || echo "$r"`
416                         upstream="$rem/$bra"
417                         if ! [ git rev-parse "$upstream" ]; then
418                                 upstream="`repobranch "$d"`"
419                         fi
420                         if git log "$upstream".."$r" | grep .; then
421                                 if yesno "Push \"$r\" in $dv?"; then
422                                         verbose git push "$rem" HEAD
423                                 fi
424                         fi
425                         if [ x"$submit" = x"-s" ]; then
426                                 case "$r" in
427                                         */*)
428                                                 verbose git push "$rem" HEAD:"${bra%%/*}/finished/${bra#*/}"
429                                                 ;;
430                                 esac
431                         fi
432                         cd "$d0"
433                 done
434                 ;;
435         compile)
436                 if [ -n "$WE_HATE_OUR_USERS" ]; then
437                         TARGETS="sv-debug cl-debug"
438                         if [ -z "$CC" ]; then
439                                 export CC=gcc
440                         fi
441                 elif [ x"`uname`" = x"Darwin" ] && ( [ -d /Library/Frameworks/SDL.framework ] || [ -d $(HOME)/Library/Frameworks/SDL.framework ] ); then
442                         # AGL is broken in Snow Leopard, so let's default to SDL if it is available.
443                         TARGETS="sv-debug sdl-debug"
444                 else
445                         TARGETS="sv-debug cl-debug sdl-debug"
446                 fi
447                 case "$1" in
448                         -c)
449                                 clean=true
450                                 shift
451                                 ;;
452                         *)
453                                 clean=false
454                                 ;;
455                 esac
456                 case "$1" in
457                         sdl)
458                                 TARGETS="sdl-debug"
459                                 shift
460                                 ;;
461                         glx|agl|wgl)
462                                 TARGETS="cl-debug"
463                                 shift
464                                 ;;
465                         dedicated)
466                                 TARGETS="sv-debug"
467                                 shift
468                                 ;;
469                 esac
470                 if [ -z "$MAKEFLAGS" ]; then
471                         if [ -f /proc/cpuinfo ]; then
472                                 ncpus=$((`grep -c '^processor   :' /proc/cpuinfo`+0))
473                                 if [ $ncpus -gt 1 ]; then
474                                         MAKEFLAGS=-j$ncpus
475                                 fi
476                         fi
477                         case "`uname`" in
478                                 Linux|*BSD)
479                                         MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
480                                         ;;
481                         esac
482                         if [ -n "$WE_HATE_OUR_USERS" ]; then
483                                 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
484                         fi
485                 fi
486                 enter "$d0/fteqcc" verbose
487                 if $clean; then
488                         verbose make $MAKEFLAGS clean
489                 fi
490                 verbose make $MAKEFLAGS
491                 enter "$d0/data/xonotic-data.pk3dir" verbose
492                 if $clean; then
493                         verbose make $MAKEFLAGS clean
494                 fi
495                 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
496                 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
497                 enter "$d0/darkplaces" verbose
498                 if $clean; then
499                         verbose make $MAKEFLAGS clean
500                 fi
501                 for T in $TARGETS; do
502                         verbose make $MAKEFLAGS "$@" "$T"
503                 done
504                 ;;
505         run)
506                 if [ -n "$WE_HATE_OUR_USERS" ]; then
507                         client=
508                         export PATH="$d0/misc/buildfiles/w32:$PATH"
509                 elif [ x"`uname`" = x"Darwin" ]; then
510                         export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/MacOS"
511                         client=-sdl
512                 else
513                         client=-sdl
514                 fi
515                 case "$1" in
516                         sdl|glx|agl|dedicated)
517                                 client=-$1
518                                 shift
519                                 ;;
520                         wgl)
521                                 client=
522                                 shift
523                                 ;;
524                 esac
525                 if ! [ -x "darkplaces/darkplaces$client" ]; then
526                         if [ -x "darkplaces/darkplaces$client.exe" ]; then
527                                 client=$client.exe
528                         else
529                                 echo "Client darkplaces/darkplaces$client not found, aborting"
530                                 exit 1
531                         fi
532                 fi
533                 set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
534
535                 # if pulseaudio is running: USE IT
536                 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ] && ! [ x"`uname`" = x"Darwin" ]; then
537                         if ps -C pulseaudio >/dev/null; then
538                                 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
539                                         export SDL_AUDIODRIVER=pulse
540                                 fi
541                         fi
542                 fi
543
544                 if [ -n "$USE_GDB" ]; then
545                         set -- gdb --args "$@"
546                 fi
547                 "$@"
548                 ;;
549         each|foreach)
550                 for d in $repos; do
551                         if verbose cd "$d0/$d"; then
552                                 verbose "$@"
553                                 cd "$d0"
554                         fi
555                 done
556                 ;;
557         save-patches)
558                 outfile=$1
559                 patchdir=`mktemp -d -t save-patches.XXXXXX`
560                 for d in $repos; do
561                         enter "$d0/$d" verbose
562                         git branch -v -v | cut -c 3- | {
563                                 i=0
564                                 while read -r BRANCH REV UPSTREAM TEXT; do
565                                         case "$UPSTREAM" in
566                                                 \[*)
567                                                         UPSTREAM=${UPSTREAM#\[}
568                                                         UPSTREAM=${UPSTREAM%\]}
569                                                         UPSTREAM=${UPSTREAM%:*}
570                                                         TRACK=true
571                                                         ;;
572                                                 *)
573                                                         UPSTREAM=origin/"`repobranch "$d"`"
574                                                         TRACK=false
575                                                         ;;
576                                         esac
577                                         if [ x"$REV" = x"->" ]; then
578                                                 continue
579                                         fi
580                                         if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
581                                                 echo "$d" > "$patchdir/$i/info.txt"
582                                                 echo "$BRANCH" >> "$patchdir/$i/info.txt"
583                                                 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
584                                                 echo "$TRACK" >> "$patchdir/$i/info.txt"
585                                                 i=$(($i+1))
586                                         else
587                                                 rm -rf "$patchdir/$i"
588                                         fi
589                                 done
590                         }
591                 done
592                 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
593                 rm -rf "$patchdir"
594                 ;;
595         restore-patches)
596                 infile=$1
597                 patchdir=`mktemp -d -t restore-patches.XXXXXX`
598                 ( cd "$patchdir" && tar xvzf - ) < "$infile"
599                 # detach the head
600                 for P in "$patchdir"/*/info.txt; do
601                         D=${P%/info.txt}
602                         exec 3<"$P"
603                         read -r d <&3
604                         read -r BRANCH <&3
605                         read -r UPSTREAM <&3
606                         read -r TRACK <&3
607                         verbose git checkout HEAD^0
608                         verbose git branch -D "$BRANCH"
609                         if [ x"$TRACK" = x"true" ]; then
610                                 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
611                         else
612                                 verbose git branch -b "$BRANCH" "$UPSTREAM"
613                         fi
614                         verbose git am "$D"
615                 done
616                 rm -rf "$patchdir"
617                 ;;
618         admin-merge)
619                 if [ "$#" = 1 ]; then
620                         set -- "${1%%/*}" "${1#*/}"
621                 fi
622                 for d in $repos; do
623                         enter "$d0/$d" verbose
624                         git rev-parse "$1/$2" || continue
625                         # 1. review
626                         {
627                                 git log HEAD.."$1/$2"
628                                 git diff HEAD..."$1/$2"
629                         } | less
630                         if yesno "Merge \"$1/$2\" into `git symbolic-ref HEAD` of $d?"; then
631                                 git merge "$1/$2"
632                                 if "$SELF" compile && yesno "Still merge \"$1/$2\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
633                                         git push origin HEAD
634                                         git push "$1" :"$2"
635                                 else
636                                         git reset --hard HEAD@{1}
637                                 fi
638                         fi
639                 done
640                 ;;
641         admin-merge-2)
642                 t=`mktemp`
643                 report=""
644                 reportecho()
645                 {
646                         report=$report"$*$LF"
647                         echo "$*"
648                 }
649                 reportecho4()
650                 {
651                         report=$report"    $*$LF"
652                         echo "    $*"
653                 }
654                 reportdo4()
655                 {
656                         o=`"$@" | sed 's/^/    /' || true`
657                         reportecho "$o"
658                 }
659                 for d in $repos; do
660                         enter "$d0/$d" verbose
661                         base="`repobranch "$d"`"
662                         reportecho "In $d:"
663                         for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
664                                 case "${ref#refs/remotes/origin/}" in
665                                         "$base")
666                                                 continue
667                                                 ;;
668                                         HEAD|master)
669                                                 continue
670                                                 ;;
671                                 esac
672                                 reportecho "  Branch $ref:"
673                                 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
674                                 if [ -n "$note" ]; then
675                                         reportdo4 echo "$note"
676                                         reportecho4 "--> not merging, already had this one rejected before"
677                                 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
678                                         git checkout "$base"
679                                         org=`git rev-parse HEAD`
680                                         if ! git merge "$ref" 2>&1 | tee "$t"; then
681                                                 git reset --hard "$org"
682                                                 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
683                                                 reportdo4 cat "$t"
684                                                 reportecho4 "--> merge failed"
685                                         elif ! "$SELF" compile 2>&1 | tee "$t"; then
686                                                 git reset --hard "$org"
687                                                 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Compile failed:$LF`cat "$t"`" "$ref"
688                                                 reportdo4 cat "$t"
689                                                 reportecho4 "--> compile failed"
690                                         elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
691                                                 git reset --hard "$org"
692                                                 git notes edit "$ref"
693                                                 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
694                                                 reportdo4 echo "$note"
695                                                 reportecho4 "--> test failed"
696                                         else
697                                                 case ",`repoflags "$d"`," in
698                                                         *,svn,*)
699                                                                 # we do quite a mess here... luckily we know $org
700                                                                 git pull # svn needs to be current
701                                                                 git rebase -i --onto master "$org"
702                                                                 git svn dcommit --add-author-from
703                                                                 git reset --hard "$org"
704                                                                 ;;
705                                                         *)
706                                                                 git push origin HEAD
707                                                                 ;;
708                                                 esac
709                                                 reportecho4 "--> MERGED"
710                                                 if yesno "Delete original branch \"$ref\"?"; then
711                                                         git push origin :"${ref#refs/remotes/origin/}"
712                                                         reportecho4 "--> branch deleted"
713                                                 fi
714                                         fi
715                                 else
716                                         git notes --ref "refs/notes/admin-merge" add "$ref"
717                                         note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
718                                         if [ -n "$note" ]; then
719                                                 reportdo4 echo "$note"
720                                                 reportecho4 "--> rejected"
721                                         else
722                                                 reportecho4 "--> postponed"
723                                         fi
724                                 fi
725                                 reportecho ""
726                         done
727                         reportecho ""
728                 done
729                 rm -f "$t"
730                 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
731                 ;;
732         *)
733                 echo "Usage:"
734                 echo "  $SELF pull"
735                 echo "  $SELF merge"
736                 echo "  $SELF push [-s]"
737                 echo "  $SELF branches"
738                 echo "  $SELF branch [<remote>] <branchname>"
739                 echo "  $SELF branch <remote> <branchname> <srcbranchname>"
740                 echo "  $SELF checkout [<remote>] <branchname>"
741                 echo "  $SELF compile [-c] [<client>] <options>"
742                 echo "  $SELF run [<client>] <options>"
743                 echo "  $SELF each <command>"
744                 ;;
745 esac