X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-clone.sh;h=b4e858c3885dab55398670d9497304eb83545d1f;hb=cd676a513672eeb9663c6d4de276a1c860a4b879;hp=24ad179bbda69ecf68e49896c3c018425b645461;hpb=25f3cd527dec9909322a0f76458a0b602de61141;p=git.git diff --git a/git-clone.sh b/git-clone.sh index 24ad179bb..b4e858c38 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -56,11 +56,12 @@ fi http_fetch () { # $1 = Remote, $2 = Local - curl -nsfL $curl_extra_args "$1" >"$2" || - case $? in - 126|127) exit ;; - *) return $? ;; - esac + curl -nsfL $curl_extra_args "$1" >"$2" + curl_exit_status=$? + case $curl_exit_status in + 126|127) exit ;; + *) return $curl_exit_status ;; + esac } clone_dumb_http () { @@ -151,7 +152,7 @@ do die "clones are always made with separate-remote layout" ;; --reference) shift; reference="$1" ;; - -o,--origin) + -o|--origin) shift; case "$1" in '') @@ -205,7 +206,10 @@ fi # it is local if base=$(get_repo_base "$repo"); then repo="$base" - local=yes + if test -z "$depth" + then + local=yes + fi fi dir="$2" @@ -229,7 +233,7 @@ cleanup() { trap cleanup 0 mkdir -p "$dir" && D=$(cd "$dir" && pwd) || usage test -n "$GIT_WORK_TREE" && mkdir -p "$GIT_WORK_TREE" && -W=$(cd "$GIT_WORK_TREE" && pwd) && export GIT_WORK_TREE="$W" +W=$(cd "$GIT_WORK_TREE" && pwd) && GIT_WORK_TREE="$W" && export GIT_WORK_TREE if test yes = "$bare" || test -n "$GIT_WORK_TREE"; then GIT_DIR="$D" else @@ -297,7 +301,8 @@ yes) find objects -type f -print | sed -e 1q) # objects directory should not be empty because # we are cloning! - test -f "$repo/$sample_file" || exit + test -f "$repo/$sample_file" || + die "fatal: cannot clone empty repository" if ln "$repo/$sample_file" "$GIT_DIR/objects/sample" 2>/dev/null then rm -f "$GIT_DIR/objects/sample"