Migrate git-clone to use git-rev-parse --parseopt

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Pierre Habouzit 2007-11-04 11:30:56 +01:00 коммит произвёл Junio C Hamano
Родитель 27c0d1c7f5
Коммит 943625998b
1 изменённых файлов: 56 добавлений и 45 удалений

Просмотреть файл

@ -8,15 +8,36 @@
# See git-sh-setup why. # See git-sh-setup why.
unset CDPATH unset CDPATH
OPTIONS_SPEC="\
git-clone [options] [--] <repo> [<dir>]
--
n,no-checkout don't create a checkout
bare create a bare repository
naked create a bare repository
l,local to clone from a local repository
no-hardlinks don't use local hardlinks, always copy
s,shared setup as a shared repository
template= path to the template directory
q,quiet be quiet
reference= reference repository
o,origin= use <name> instead of 'origin' to track upstream
u,upload-pack= path to git-upload-pack on the remote
depth= create a shallow clone of that depth
use-separate-remote compatibility, do not use
no-separate-remote compatibility, do not use"
die() { die() {
echo >&2 "$@" echo >&2 "$@"
exit 1 exit 1
} }
usage() { usage() {
die "Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [--depth <n>] [-n] [--] <repo> [<dir>]" exec "$0" -h
} }
eval `echo "$OPTIONS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?`
get_repo_base() { get_repo_base() {
( (
cd "`/bin/pwd`" && cd "`/bin/pwd`" &&
@ -106,67 +127,57 @@ depth=
no_progress= no_progress=
local_explicitly_asked_for= local_explicitly_asked_for=
test -t 1 || no_progress=--no-progress test -t 1 || no_progress=--no-progress
while
case "$#,$1" in while test $# != 0
0,*) break ;; do
*,-n|*,--no|*,--no-|*,--no-c|*,--no-ch|*,--no-che|*,--no-chec|\ case "$1" in
*,--no-check|*,--no-checko|*,--no-checkou|*,--no-checkout) -n|--no-checkout)
no_checkout=yes ;; no_checkout=yes ;;
*,--na|*,--nak|*,--nake|*,--naked|\ --naked|--bare)
*,-b|*,--b|*,--ba|*,--bar|*,--bare) bare=yes ;; bare=yes ;;
*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) -l|--local)
local_explicitly_asked_for=yes local_explicitly_asked_for=yes
use_local_hardlink=yes ;; use_local_hardlink=yes
*,--no-h|*,--no-ha|*,--no-har|*,--no-hard|*,--no-hardl|\ ;;
*,--no-hardli|*,--no-hardlin|*,--no-hardlink|*,--no-hardlinks) --no-hardlinks)
use_local_hardlink=no ;; use_local_hardlink=no ;;
*,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) -s|--shared)
local_shared=yes; ;; local_shared=yes ;;
1,--template) usage ;; --template)
*,--template)
shift; template="--template=$1" ;; shift; template="--template=$1" ;;
*,--template=*) -q|--quiet)
template="$1" ;; quiet=-q ;;
*,-q|*,--quiet) quiet=-q ;; --use-separate-remote|--no-separate-remote)
*,--use-separate-remote) ;;
*,--no-separate-remote)
die "clones are always made with separate-remote layout" ;; die "clones are always made with separate-remote layout" ;;
1,--reference) usage ;; --reference)
*,--reference)
shift; reference="$1" ;; shift; reference="$1" ;;
*,--reference=*) -o,--origin)
reference=`expr "z$1" : 'z--reference=\(.*\)'` ;; shift;
*,-o|*,--or|*,--ori|*,--orig|*,--origi|*,--origin) case "$1" in
case "$2" in
'') '')
usage ;; usage ;;
*/*) */*)
die "'$2' is not suitable for an origin name" die "'$1' is not suitable for an origin name"
esac esac
git check-ref-format "heads/$2" || git check-ref-format "heads/$1" ||
die "'$2' is not suitable for a branch name" die "'$1' is not suitable for a branch name"
test -z "$origin_override" || test -z "$origin_override" ||
die "Do not give more than one --origin options." die "Do not give more than one --origin options."
origin_override=yes origin_override=yes
origin="$2"; shift origin="$1"
;; ;;
1,-u|1,--upload-pack) usage ;; -u|--upload-pack)
*,-u|*,--upload-pack)
shift shift
upload_pack="--upload-pack=$1" ;; upload_pack="--upload-pack=$1" ;;
*,--upload-pack=*) --depth)
upload_pack=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
1,--depth) usage;;
*,--depth)
shift shift
depth="--depth=$1";; depth="--depth=$1" ;;
*,--) --)
shift shift
break ;; break ;;
*,-*) usage ;; *)
*) break ;; usage ;;
esac esac
do
shift shift
done done