Why didn't we mark want_obj as ~UNINTERESTING in the old code?
[gitweb.git] / git-clone.sh
index 3f006d1a778636e5906ad9e8671adb6561fa0d98..8c0a93ebd15399fad6f58fcf315709cb94fd6128 100755 (executable)
@@ -14,7 +14,7 @@ die() {
 }
 
 usage() {
-       die "Usage: $0 [--template=<template_directory>] [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
+       die "Usage: $0 [--template=<template_directory>] [--use-immingled-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [--depth <n>] [-n] <repo> [<dir>]"
 }
 
 get_repo_base() {
@@ -115,7 +115,8 @@ bare=
 reference=
 origin=
 origin_override=
-use_separate_remote=
+use_separate_remote=t
+depth=
 while
        case "$#,$1" in
        0,*) break ;;
@@ -134,7 +135,10 @@ while
          template="$1" ;;
        *,-q|*,--quiet) quiet=-q ;;
        *,--use-separate-remote)
+               # default
                use_separate_remote=t ;;
+       *,--use-immingled-remote)
+               use_separate_remote= ;;
        1,--reference) usage ;;
        *,--reference)
                shift; reference="$1" ;;
@@ -158,6 +162,10 @@ while
        *,-u|*,--upload-pack)
                shift
                upload_pack="--exec=$1" ;;
+       1,--depth) usage;;
+       *,--depth)
+               shift
+               depth="--depth=$1";;
        *,-*) usage ;;
        *) break ;;
        esac
@@ -169,18 +177,15 @@ repo="$1"
 test -n "$repo" ||
     die 'you must specify a repository to clone.'
 
-# --bare implies --no-checkout
+# --bare implies --no-checkout and --use-immingled-remote
 if test yes = "$bare"
 then
        if test yes = "$origin_override"
        then
                die '--bare and --origin $origin options are incompatible.'
        fi
-       if test t = "$use_separate_remote"
-       then
-               die '--bare and --use-separate-remote options are incompatible.'
-       fi
        no_checkout=yes
+       use_separate_remote=
 fi
 
 if test -z "$origin"
@@ -265,6 +270,10 @@ yes,yes)
 *)
        case "$repo" in
        rsync://*)
+               case "$depth" in
+               "") ;;
+               *) die "shallow over rsync not supported" ;;
+               esac
                rsync $quiet -av --ignore-existing  \
                        --exclude info "$repo/objects/" "$GIT_DIR/objects/" ||
                exit
@@ -293,6 +302,10 @@ yes,yes)
                git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
                ;;
        https://*|http://*|ftp://*)
+               case "$depth" in
+               "") ;;
+               *) die "shallow over http or ftp not supported" ;;
+               esac
                if test -z "@@NO_CURL@@"
                then
                        clone_dumb_http "$repo" "$D"
@@ -302,8 +315,8 @@ yes,yes)
                ;;
        *)
                case "$upload_pack" in
-               '') git-fetch-pack --all -k $quiet "$repo" ;;
-               *) git-fetch-pack --all -k $quiet "$upload_pack" "$repo" ;;
+               '') git-fetch-pack --all -k $quiet $depth "$repo" ;;
+               *) git-fetch-pack --all -k $quiet "$upload_pack" $depth "$repo" ;;
                esac >"$GIT_DIR/CLONE_HEAD" ||
                        die "fetch-pack from '$repo' failed."
                ;;