{"thread":{"id":"8476","subject":"[PATCH] Fix clone to setup the origin if its name ends with .git","startedAt":"2007-06-06T22:49:06Z","lastAt":"2007-06-07T02:08:28Z","messageCount":2,"participants":["Alex Riesen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"44206","messageId":"20070606224906.GB3969@steel.home","threadId":"8476","inReplyTo":null,"subject":"[PATCH] Fix clone to setup the origin if its name ends with .git","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-06T22:49:06Z","receivedAt":"2007-06-06T22:49:06Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"The problem is visible when cloning a local repo. The cloned\nrepository will have the origin url setup incorrectly: the origin name\nwill be copied verbatim in origin url of the cloned repository.\nNormally, the name is to be expanded into absolute path.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n git-clone.sh           |    2 +-\n t/t5701-clone-local.sh |   17 +++++++++++++++++\n 2 files changed, 18 insertions(+), 1 deletions(-)\n create mode 100755 t/t5701-clone-local.sh\n\ndiff --git a/git-clone.sh b/git-clone.sh\nindex fdd354f..d45618d 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -20,7 +20,7 @@ usage() {\n get_repo_base() {\n \t(\n \t\tcd \"`/bin/pwd`\" &&\n-\t\tcd \"$1\" &&\n+\t\tcd \"$1\" || cd \"$1.git\" &&\n \t\t{\n \t\t\tcd .git\n \t\t\tpwd\ndiff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh\nnew file mode 100755\nindex 0000000..fb027f3\n--- /dev/null\n+++ b/t/t5701-clone-local.sh\n@@ -0,0 +1,17 @@\n+#!/bin/sh\n+\n+test_description='test local clone'\n+. ./test-lib.sh\n+\n+test_expect_success 'preparing origin repository' \\\n+':>file && git add . && git commit -m1 && mv .git a.git'\n+\n+unset GIT_CONFIG\n+\n+test_expect_success 'local clone without .git suffix' \\\n+'git clone -l -s a b && cd b && git fetch && cd ..'\n+\n+test_expect_success 'local clone with .git suffix' \\\n+'git clone -l -s a.git c && cd c && git fetch && cd ..'\n+\n+test_done\n-- \n1.5.2.1.141.g3c63\n"},{"id":"44213","messageId":"7vejkott2b.fsf@assigned-by-dhcp.cox.net","threadId":"8476","inReplyTo":"20070606224906.GB3969@steel.home","subject":"Re: [PATCH] Fix clone to setup the origin if its name ends with .git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-07T02:08:28Z","receivedAt":"2007-06-07T02:08:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> The problem is visible when cloning a local repo. The cloned\n> repository will have the origin url setup incorrectly: the origin name\n> will be copied verbatim in origin url of the cloned repository.\n> Normally, the name is to be expanded into absolute path.\n\nThanks.\n\n> diff --git a/git-clone.sh b/git-clone.sh\n> index fdd354f..d45618d 100755\n> --- a/git-clone.sh\n> +++ b/git-clone.sh\n> @@ -20,7 +20,7 @@ usage() {\n>  get_repo_base() {\n>  \t(\n>  \t\tcd \"`/bin/pwd`\" &&\n> -\t\tcd \"$1\" &&\n> +\t\tcd \"$1\" || cd \"$1.git\" &&\n>  \t\t{\n>  \t\t\tcd .git\n>  \t\t\tpwd\n\nWe would probably need a to clean up this test a bit, though.\nWhen we write our tests, we tend to forget testing the cases\nwhere things ought to fail.\n\nI'll probably redo the test myself, but for the record...\n\n - Please never \"unset\" GIT_CONFIG.  We do not want the tests to\n   get affected with /etc/gitconfig or $HOME/.gitconfig;\n\n - We would also want to test the cases where a bare repository\n   x exists and x.git does not, and try cloning it into y and z\n   respectively.  Obviously the former should work and the\n   latter should fail.\n"}]}