[PATCH] git-cvsimport-script: add "import only" option
[git.git] / git-clone-script
index 4f80ade..5a241fb 100755 (executable)
@@ -10,11 +10,17 @@ usage() {
        exit 1
 }
 
+get_repo_base() {
+       (cd "$1" && (cd .git ; pwd)) 2> /dev/null
+}
+
+quiet=
 use_local=no
 while
        case "$#,$1" in
        0,*) break ;;
         *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;
+       *,-q|*,--quiet) quiet=-q ;;
        *,-*) usage ;;
        *) break ;;
        esac
@@ -22,7 +28,15 @@ do
        shift
 done
 
+# Turn the source into an absolute path if
+# it is local
 repo="$1"
+local=no
+if base=$(get_repo_base "$repo"); then
+       repo="$base"
+       local=yes
+fi
+
 dir="$2"
 mkdir "$dir" &&
 D=$(
@@ -31,8 +45,8 @@ D=$(
 test -d "$D" || usage
 
 # We do local magic only when the user tells us to.
-case "$use_local" in
-yes)
+case "$local,$use_local" in
+yes,yes)
        ( cd "$repo/objects" ) || {
                repo="$repo/.git"
                ( cd "$repo/objects" ) || {
@@ -67,4 +81,16 @@ yes)
        ;;
 esac
 
-cd "$D" && git clone-pack "$repo"
+case "$repo" in
+rsync://*)
+       rsync $quiet -avz --ignore-existing "$repo/objects/" "$D/.git/objects/" &&
+       rsync $quiet -avz --ignore-existing "$repo/refs/" "$D/.git/refs/"
+       ;;
+http://*)
+       echo "Somebody should add http fetch" >&2
+       exit 1
+       ;;
+*)
+       cd "$D" && git-clone-pack $quiet "$repo"
+       ;;
+esac