зеркало из https://github.com/microsoft/git.git
git-clone: split up long &&-command-chain and use a function for cleanup
Signed-off-by: Matthias Lederhofer <matled@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
8960b5a7df
Коммит
68ad8910f7
17
git-clone.sh
17
git-clone.sh
|
@ -187,15 +187,24 @@ dir="$2"
|
||||||
# Try using "humanish" part of source repo if user didn't specify one
|
# Try using "humanish" part of source repo if user didn't specify one
|
||||||
[ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
|
[ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
|
||||||
[ -e "$dir" ] && die "destination directory '$dir' already exists."
|
[ -e "$dir" ] && die "destination directory '$dir' already exists."
|
||||||
mkdir -p "$dir" &&
|
D=
|
||||||
D=$(cd "$dir" && pwd) &&
|
cleanup() {
|
||||||
trap 'err=$?; cd ..; rm -rf "$D"; exit $err' 0
|
err=$?
|
||||||
|
test -z "$D" && rm -rf "$dir"
|
||||||
|
cd ..
|
||||||
|
test -n "$D" && rm -rf "$D"
|
||||||
|
exit $err
|
||||||
|
}
|
||||||
|
trap cleanup 0
|
||||||
|
mkdir -p "$dir" && D=$(cd "$dir" && pwd) || usage
|
||||||
case "$bare" in
|
case "$bare" in
|
||||||
yes)
|
yes)
|
||||||
GIT_DIR="$D" ;;
|
GIT_DIR="$D" ;;
|
||||||
*)
|
*)
|
||||||
GIT_DIR="$D/.git" ;;
|
GIT_DIR="$D/.git" ;;
|
||||||
esac && export GIT_DIR && git init $quiet ${template+"$template"} || usage
|
esac &&
|
||||||
|
export GIT_DIR &&
|
||||||
|
git-init $quiet ${template+"$template"} || usage
|
||||||
|
|
||||||
if test -n "$reference"
|
if test -n "$reference"
|
||||||
then
|
then
|
||||||
|
|
Загрузка…
Ссылка в новой задаче