+ fix_config=false
+ location=current
+ while :; do
+ if [ x"$1" = x"-N" ]; then
+ allow_pull=false
+ elif [ x"$1" = x"-p" ]; then
+ fix_config=true
+ pushbase=ssh://xonotic@git.xonotic.org/
+ elif [ x"$1" = x"-ps" ]; then
+ fix_config=true
+ pushbase=ssh://xonotic@git.xonotic.org/
+ elif [ x"$1" = x"-ph" ]; then
+ fix_config=true
+ pushbase=http://git.xonotic.org/login/xonotic/
+ elif [ x"$1" = x"-s" ]; then
+ fix_config=true
+ base=ssh://xonotic@git.xonotic.org/
+ elif [ x"$1" = x"-g" ]; then
+ fix_config=true
+ base=git://git.xonotic.org/xonotic/
+ elif [ x"$1" = x"-h" ]; then
+ fix_config=true
+ base=http://git.xonotic.org/xonotic/
+ elif [ x"$1" = x"-l" ]; then
+ case "$2" in
+ nl) ;;
+ de) ;;
+ us) ;;
+ best) ;;
+ default) ;;
+ *)
+ msg "Invalid location!"
+ msg "Possible locations for the -l option:"
+ msg " nl (Netherlands, run by merlijn)"
+ msg " de (Germany, run by divVerent)"
+ msg " us (United States of America, run by detrate)"
+ msg " best (find automatically)"
+ msg " default (currently nl)"
+ exit 1
+ ;;
+ esac
+ fix_config=true
+ location=$2
+ shift
+ else
+ break
+ fi
+ shift
+ done
+ case "$location" in
+ current)
+ if [ x"`git config xonotic.all.mirrorselection 2>/dev/null || true`" != x"done" ]; then
+ git config xonotic.all.mirrorselection done
+ location=best
+ fi
+ ;;
+ esac
+ case "$location" in
+ best)
+ # if we fetched via ssh://, switch to git:// for fetching and keep using ssh:// for pushing
+ case "$base" in
+ ssh://*|*/login/*)
+ pushbase=$base
+ base=git://git.xonotic.org/xonotic/
+ ;;
+ esac
+ newbase=`$ECHO "$base" | sed "s,://\(.*\.\)\?git.xonotic.org/,:// .git.xonotic.org/,"`
+ case "$newbase" in
+ *\ *)
+ if location=`bestmirror $newbase"xonotic.git" de us nl:'*6/5'`; then # 20% malus to the NL server to not overload it too much
+ :
+ else
+ location=current
+ fi
+ ;;
+ *)
+ location=current
+ ;;
+ esac
+ ;;
+ esac
+ case "$location" in
+ default)
+ location=
+ ;;
+ current)
+ case "$base" in
+ *://*.git.xonotic.org/*)
+ location=${base%%.git.xonotic.org/*}
+ location=${location##*://}
+ ;;
+ *)
+ location=
+ ;;
+ esac
+ ;;
+ esac
+ if [ -n "$location" ]; then
+ base=`$ECHO "$base" | sed "s,://\(.*\.\)\?git.xonotic.org/,://$location.git.xonotic.org/,"`
+ pushbase=`$ECHO "$pushbase" | sed "s,://\(.*\.\)\?git.xonotic.org/,://$location.git.xonotic.org/,"`
+ else
+ base=`$ECHO "$base" | sed "s,://\(.*\.\)\?git.xonotic.org/,://git.xonotic.org/,"`
+ pushbase=`$ECHO "$pushbase" | sed "s,://\(.*\.\)\?git.xonotic.org/,://git.xonotic.org/,"`