unset CDPATH
usage() {
- echo >&2 "* git clone [-l [-s]] [-q] [-u <upload-pack>] [-n] <repo> <dir>"
+ echo >&2 "* git clone [-l [-s]] [-q] [-u <upload-pack>] [-n] <repo> [<dir>]"
exit 1
}
*,-n) no_checkout=yes ;;
*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;
*,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared)
- local_shared=yes ;;
+ local_shared=yes; use_local=yes ;;
*,-q|*,--quiet) quiet=-q ;;
1,-u|1,--upload-pack) usage ;;
*,-u|*,--upload-pack)
fi
dir="$2"
-mkdir "$dir" &&
+# 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')
+[ -e "$dir" ] && echo "$dir already exists." && usage
+mkdir -p "$dir" &&
D=$(
(cd "$dir" && git-init-db && pwd)
) &&
rm -f "$D/.git/TMP_ALT"
if test -f "$D/.git/TMP_ALT"
then
- ( cd $D &&
+ ( cd "$D" &&
. git-parse-remote &&
resolve_alternates "$repo" <"./.git/TMP_ALT" ) |
while read alt
;;
esac
-cd $D || exit
+cd "$D" || exit
if test -f ".git/HEAD"
then