{"thread":{"id":"12350","subject":"[PATCHv3] clone: support cloning full bundles","startedAt":"2008-02-28T02:22:52Z","lastAt":"2008-02-29T19:16:19Z","messageCount":3,"participants":["Santi Béjar","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"70197","messageId":"1204165372-12175-1-git-send-email-sbejar@gmail.com","threadId":"12350","inReplyTo":null,"subject":"[PATCHv3] clone: support cloning full bundles","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-02-28T02:22:52Z","receivedAt":"2008-02-28T02:22:52Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"The \"humanish\" part of a bundle is made removing the \".bundle\" suffix.\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\nHi,\n\n  Just in case .bundle is the definitive suffix.\n\n  Changes since v2:\n\n  . fixed the && [ -f \"$repo\" ] test\n  . make \"offically\" the .bundle suffix\n  . test that \"git fetch\" works after the cloning\n  . additional tests\n\nSanti\n\n git-clone.sh           |   19 ++++++++++++++-----\n t/t5701-clone-local.sh |   45 +++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 59 insertions(+), 5 deletions(-)\n\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 0d686c3..0580b5a 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -210,11 +210,14 @@ if base=$(get_repo_base \"$repo\"); then\n \tthen\n \t\tlocal=yes\n \tfi\n+elif [ -f \"$repo\" ] ; then\n+\tcase \"$repo\" in /*);; *) repo=\"$PWD/$repo\" ; esac\n fi\n \n dir=\"$2\"\n # Try using \"humanish\" part of source repo if user didn't specify one\n-[ -z \"$dir\" ] && dir=$(echo \"$repo\" | sed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\n+[ -z \"$dir\" ] && dir=$(echo \"$repo\" | sed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g') &&\n+[ -f \"$repo\" ] && dir=$(echo \"$repo\" | sed -e 's|/*\\.bundle$||' -e 's|.*/||g')\n [ -e \"$dir\" ] && die \"destination directory '$dir' already exists.\"\n [ yes = \"$bare\" ] && unset GIT_WORK_TREE\n [ -n \"$GIT_WORK_TREE\" ] && [ -e \"$GIT_WORK_TREE\" ] &&\n@@ -364,11 +367,17 @@ yes)\n \t\tfi\n \t\t;;\n \t*)\n-\t\tcase \"$upload_pack\" in\n-\t\t'') git-fetch-pack --all -k $quiet $depth $no_progress \"$repo\";;\n-\t\t*) git-fetch-pack --all -k $quiet \"$upload_pack\" $depth $no_progress \"$repo\" ;;\n-\t\tesac >\"$GIT_DIR/CLONE_HEAD\" ||\n+\t\tif [ -f \"$repo\" ] ; then\n+\t\t\tgit bundle unbundle \"$repo\" > \"$GIT_DIR/CLONE_HEAD\" ||\n+\t\t\tdie \"unbundle from '$repo' failed.\"\n+\t\telse\n+\t\t\tcase \"$upload_pack\" in\n+\t\t\t'') git-fetch-pack --all -k $quiet $depth $no_progress \"$repo\";;\n+\t\t\t*) git-fetch-pack --all -k \\\n+\t\t\t\t$quiet \"$upload_pack\" $depth $no_progress \"$repo\" ;;\n+\t\t\tesac >\"$GIT_DIR/CLONE_HEAD\" ||\n \t\t\tdie \"fetch-pack from '$repo' failed.\"\n+\t\tfi\n \t\t;;\n \tesac\n \t;;\ndiff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh\nindex 59a165a..ef2db00 100755\n--- a/t/t5701-clone-local.sh\n+++ b/t/t5701-clone-local.sh\n@@ -11,6 +11,11 @@ test_expect_success 'preparing origin repository' '\n \tgit clone --bare . x &&\n \ttest \"$(GIT_CONFIG=a.git/config git config --bool core.bare)\" = true &&\n \ttest \"$(GIT_CONFIG=x/config git config --bool core.bare)\" = true\n+\tgit bundle create b1.bundle --all HEAD &&\n+\tgit bundle create b2.bundle --all &&\n+\tmkdir dir &&\n+\tcp b1.bundle dir/b3\n+\tcp b1.bundle b4\n '\n \n test_expect_success 'local clone without .git suffix' '\n@@ -71,4 +76,44 @@ test_expect_success 'local clone of repo with nonexistent ref in HEAD' '\n \tgit fetch &&\n \ttest ! -e .git/refs/remotes/origin/HEAD'\n \n+test_expect_success 'bundle clone without .bundle suffix' '\n+\tcd \"$D\" &&\n+\tgit clone dir/b3 &&\n+\tcd b3 &&\n+\tgit fetch\n+'\n+\n+test_expect_success 'bundle clone with .bundle suffix' '\n+\tcd \"$D\" &&\n+\tgit clone b1.bundle &&\n+\tcd b1 &&\n+\tgit fetch\n+'\n+\n+test_expect_success 'bundle clone from b4' '\n+\tcd \"$D\" &&\n+\tgit clone b1.bundle bdl1 &&\n+\tcd bdl1 &&\n+\tgit fetch\n+'\n+\n+test_expect_success 'bundle clone from b4.bundle that does not exist' '\n+\tcd \"$D\" &&\n+\tif git clone b4.bundle bb\n+\tthen\n+\t\techo \"Oops, should have failed\"\n+\t\tfalse\n+\telse\n+\t\techo happy\n+\tfi\n+'\n+\n+test_expect_success 'bundle clone with nonexistent HEAD' '\n+\tcd \"$D\" &&\n+\tgit clone b2.bundle b2 &&\n+\tcd b2 &&\n+\tgit fetch\n+\ttest ! -e .git/refs/heads/master\n+'\n+\n test_done\n-- \n1.5.4.3.221.gf0f3f\n"},{"id":"70286","messageId":"7vmyplj75o.fsf@gitster.siamese.dyndns.org","threadId":"12350","inReplyTo":"1204165372-12175-1-git-send-email-sbejar@gmail.com","subject":"Re: [PATCHv3] clone: support cloning full bundles","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-28T17:57:23Z","receivedAt":"2008-02-28T17:57:23Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santi Béjar <sbejar@gmail.com> writes:\n\n> diff --git a/git-clone.sh b/git-clone.sh\n> index 0d686c3..0580b5a 100755\n> --- a/git-clone.sh\n> +++ b/git-clone.sh\n> @@ -210,11 +210,14 @@ if base=$(get_repo_base \"$repo\"); then\n>  \tthen\n>  \t\tlocal=yes\n>  \tfi\n> +elif [ -f \"$repo\" ] ; then\n> +\tcase \"$repo\" in /*);; *) repo=\"$PWD/$repo\" ; esac\n>  fi\n>  \n>  dir=\"$2\"\n>  # Try using \"humanish\" part of source repo if user didn't specify one\n> -[ -z \"$dir\" ] && dir=$(echo \"$repo\" | sed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\n> +[ -z \"$dir\" ] && dir=$(echo \"$repo\" | sed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g') &&\n> +[ -f \"$repo\" ] && dir=$(echo \"$repo\" | sed -e 's|/*\\.bundle$||' -e 's|.*/||g')\n>  [ -e \"$dir\" ] && die \"destination directory '$dir' already exists.\"\n>  [ yes = \"$bare\" ] && unset GIT_WORK_TREE\n>  [ -n \"$GIT_WORK_TREE\" ] && [ -e \"$GIT_WORK_TREE\" ] &&\n\nThis sequence was terse, to the point and very readable when the\nlogic was simpler, but now it is getting out of hand.  I think\nit is a time for rewriting to something more verbose, like...\n\n\t# Decide the directory name of the new repository\n        if test -n \"$2\"\n        then\n        \tdir=\"$2\"\n\telse\n        \t# Derive one from the repository name\n                if test -f \"$repo\"\n                then\n                        # Cloning from a bundle\n                        dir=... humanish ...\n                else\n                        dir=... humanish ...\n                fi\n        fi\n\n"},{"id":"70407","messageId":"1204312579-8303-1-git-send-email-sbejar@gmail.com","threadId":"12350","inReplyTo":"1204165372-12175-1-git-send-email-sbejar@gmail.com","subject":"[PATCHv2] clone: support cloning full bundles","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-02-29T19:16:19Z","receivedAt":"2008-02-29T19:16:19Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"The \"humanish\" part of a bundle is made removing the \".bundle\" suffix.\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\nHi,\n\n  changes since v3:\n\n  * rewrite \"humanish\" part to be more readable\n    as requested by Junio\n  * Fix a typo in one test\n\n  Santi\n\n git-clone.sh           |   36 +++++++++++++++++++++++++++++-------\n t/t5701-clone-local.sh |   45 +++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 74 insertions(+), 7 deletions(-)\n\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 0d686c3..9ae9646 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -210,11 +210,27 @@ if base=$(get_repo_base \"$repo\"); then\n \tthen\n \t\tlocal=yes\n \tfi\n+elif [ -f \"$repo\" ] ; then\n+\tcase \"$repo\" in /*);; *) repo=\"$PWD/$repo\" ; esac\n+fi\n+\n+# Decide the directory name of the new repository\n+if test -n \"$2\"\n+then\n+\tdir=\"$2\"\n+else\n+\t# Derive one from the repository name\n+\t# Try using \"humanish\" part of source repo if user didn't specify one\n+\tif test -f \"$repo\"\n+\tthen\n+\t\t# Cloning from a bundle\n+\t\tdir=$(echo \"$repo\" | sed -e 's|/*\\.bundle$||' -e 's|.*/||g')\n+\telse\n+\t\tdir=$(echo \"$repo\" |\n+\t\t\tsed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\n+\tfi\n fi\n \n-dir=\"$2\"\n-# Try using \"humanish\" part of source repo if user didn't specify one\n-[ -z \"$dir\" ] && dir=$(echo \"$repo\" | sed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\n [ -e \"$dir\" ] && die \"destination directory '$dir' already exists.\"\n [ yes = \"$bare\" ] && unset GIT_WORK_TREE\n [ -n \"$GIT_WORK_TREE\" ] && [ -e \"$GIT_WORK_TREE\" ] &&\n@@ -364,11 +380,17 @@ yes)\n \t\tfi\n \t\t;;\n \t*)\n-\t\tcase \"$upload_pack\" in\n-\t\t'') git-fetch-pack --all -k $quiet $depth $no_progress \"$repo\";;\n-\t\t*) git-fetch-pack --all -k $quiet \"$upload_pack\" $depth $no_progress \"$repo\" ;;\n-\t\tesac >\"$GIT_DIR/CLONE_HEAD\" ||\n+\t\tif [ -f \"$repo\" ] ; then\n+\t\t\tgit bundle unbundle \"$repo\" > \"$GIT_DIR/CLONE_HEAD\" ||\n+\t\t\tdie \"unbundle from '$repo' failed.\"\n+\t\telse\n+\t\t\tcase \"$upload_pack\" in\n+\t\t\t'') git-fetch-pack --all -k $quiet $depth $no_progress \"$repo\";;\n+\t\t\t*) git-fetch-pack --all -k \\\n+\t\t\t\t$quiet \"$upload_pack\" $depth $no_progress \"$repo\" ;;\n+\t\t\tesac >\"$GIT_DIR/CLONE_HEAD\" ||\n \t\t\tdie \"fetch-pack from '$repo' failed.\"\n+\t\tfi\n \t\t;;\n \tesac\n \t;;\ndiff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh\nindex 59a165a..8dfaaa4 100755\n--- a/t/t5701-clone-local.sh\n+++ b/t/t5701-clone-local.sh\n@@ -11,6 +11,11 @@ test_expect_success 'preparing origin repository' '\n \tgit clone --bare . x &&\n \ttest \"$(GIT_CONFIG=a.git/config git config --bool core.bare)\" = true &&\n \ttest \"$(GIT_CONFIG=x/config git config --bool core.bare)\" = true\n+\tgit bundle create b1.bundle --all HEAD &&\n+\tgit bundle create b2.bundle --all &&\n+\tmkdir dir &&\n+\tcp b1.bundle dir/b3\n+\tcp b1.bundle b4\n '\n \n test_expect_success 'local clone without .git suffix' '\n@@ -71,4 +76,44 @@ test_expect_success 'local clone of repo with nonexistent ref in HEAD' '\n \tgit fetch &&\n \ttest ! -e .git/refs/remotes/origin/HEAD'\n \n+test_expect_success 'bundle clone without .bundle suffix' '\n+\tcd \"$D\" &&\n+\tgit clone dir/b3 &&\n+\tcd b3 &&\n+\tgit fetch\n+'\n+\n+test_expect_success 'bundle clone with .bundle suffix' '\n+\tcd \"$D\" &&\n+\tgit clone b1.bundle &&\n+\tcd b1 &&\n+\tgit fetch\n+'\n+\n+test_expect_success 'bundle clone from b4' '\n+\tcd \"$D\" &&\n+\tgit clone b4 bdl &&\n+\tcd bdl &&\n+\tgit fetch\n+'\n+\n+test_expect_success 'bundle clone from b4.bundle that does not exist' '\n+\tcd \"$D\" &&\n+\tif git clone b4.bundle bb\n+\tthen\n+\t\techo \"Oops, should have failed\"\n+\t\tfalse\n+\telse\n+\t\techo happy\n+\tfi\n+'\n+\n+test_expect_success 'bundle clone with nonexistent HEAD' '\n+\tcd \"$D\" &&\n+\tgit clone b2.bundle b2 &&\n+\tcd b2 &&\n+\tgit fetch\n+\ttest ! -e .git/refs/heads/master\n+'\n+\n test_done\n-- \n1.5.4.3.393.g5540\n\n"}]}