X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-clone.sh;h=e98112277839349a47c26e69ce30982604d12d2c;hb=ae90e16a3a7586bc25b7c7de50e4c3ba4806b3b9;hp=0d686c3a03a15d73e086d3a54afeee269365ffcd;hpb=6fe870f032e4a247cdcf2949bb24d103873ff597;p=git.git diff --git a/git-clone.sh b/git-clone.sh index 0d686c3a0..e98112277 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -210,11 +210,28 @@ if base=$(get_repo_base "$repo"); then then local=yes fi +elif test -f "$repo" +then + case "$repo" in /*) ;; *) repo="$PWD/$repo" ;; esac +fi + +# Decide the directory name of the new repository +if test -n "$2" +then + dir="$2" +else + # Derive one from the repository name + # Try using "humanish" part of source repo if user didn't specify one + if test -f "$repo" + then + # Cloning from a bundle + dir=$(echo "$repo" | sed -e 's|/*\.bundle$||' -e 's|.*/||g') + else + dir=$(echo "$repo" | + sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g') + fi fi -dir="$2" -# 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" ] && die "destination directory '$dir' already exists." [ yes = "$bare" ] && unset GIT_WORK_TREE [ -n "$GIT_WORK_TREE" ] && [ -e "$GIT_WORK_TREE" ] && @@ -364,11 +381,17 @@ yes) fi ;; *) - case "$upload_pack" in - '') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";; - *) git-fetch-pack --all -k $quiet "$upload_pack" $depth $no_progress "$repo" ;; - esac >"$GIT_DIR/CLONE_HEAD" || + if [ -f "$repo" ] ; then + git bundle unbundle "$repo" > "$GIT_DIR/CLONE_HEAD" || + die "unbundle from '$repo' failed." + else + case "$upload_pack" in + '') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";; + *) git-fetch-pack --all -k \ + $quiet "$upload_pack" $depth $no_progress "$repo" ;; + esac >"$GIT_DIR/CLONE_HEAD" || die "fetch-pack from '$repo' failed." + fi ;; esac ;;