{"thread":{"id":"2426","subject":"[PATCH 1/2] git-clone: Keep remote names when cloning unless explicitly told not to.","startedAt":"2005-11-10T11:58:08Z","lastAt":"2005-11-10T17:49:12Z","messageCount":3,"participants":["Andreas Ericsson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"11470","messageId":"20051110115808.418125BF88@nox.op5.se","threadId":"2426","inReplyTo":null,"subject":"[PATCH 1/2] git-clone: Keep remote names when cloning unless explicitly told not to.","fromName":"Andreas Ericsson","fromEmail":"exon@op5.se","sentAt":"2005-11-10T11:58:08Z","receivedAt":"2005-11-10T11:58:08Z","isPatch":true,"sender":{"key":"exon@op5.se","avatar":"https://gravatar.com/avatar/b948c4f759e868f8e721e545e37afe2cf89cfa8e2ee8b70a432f0d76aee39891?d=mp&s=160"},"body":"\nWith this patch the following commands all clone into the local directory\n\"repo\". If repo exists, it will still barf.\n\n\tgit-clone git://host.xz/repo.git\n\tgit-clone /path/to/repo/.git\n\tgit-clone host.xz:repo.git\n\nI ended up doing the same source-to-target sed'ing for all our company\nprojects, so it was easier to add it directly to git-clone.\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n\n---\n\n Documentation/git-clone.txt |   12 +++++++-----\n git-clone.sh                |    2 ++\n 2 files changed, 9 insertions(+), 5 deletions(-)\n\napplies-to: 6466c53ae80cddbb581c5fdb2332f9321fade867\nfe6fb0e830253803798a2b70222d72e4107db1c1\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex fefd298..83f58ae 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -8,7 +8,7 @@ git-clone - Clones a repository.\n \n SYNOPSIS\n --------\n-'git-clone' [-l [-s]] [-q] [-n] [-u <upload-pack>] <repository> <directory>\n+'git-clone' [-l [-s]] [-q] [-n] [-u <upload-pack>] <repository> [<directory>]\n \n DESCRIPTION\n -----------\n@@ -68,9 +68,11 @@ OPTIONS\n \tbe any URL git-fetch supports.\n \n <directory>::\n-\tThe name of a new directory to be cloned into.  It is an\n-\terror to specify an existing directory.\n-\n+\tThe name of a new directory to clone into.  The\t\"humanish\"\n+\tpart of the source repository is used if no directory is\n+\texplicitly given (\"repo\" for \"/path/to/repo.git\" and \"foo\"\n+\tfor \"host.xz:foo/.git\").  Cloning into an existing directory\n+\tis not allowed.\n \n Author\n ------\n@@ -78,7 +80,7 @@ Written by Linus Torvalds <torvalds@osdl\n \n Documentation\n --------------\n-Documentation by Junio C Hamano.\n+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.\n \n \n GIT\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 4fdd652..70cf7a2 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -96,6 +96,8 @@ if base=$(get_repo_base \"$repo\"); then\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#/*\\.git$##' -e 's#.*[/:]##')\n mkdir \"$dir\" &&\n D=$(\n \t(cd \"$dir\" && git-init-db && pwd)\n---\n0.99.9.GIT\n"},{"id":"11484","messageId":"7vd5l81l15.fsf@assigned-by-dhcp.cox.net","threadId":"2426","inReplyTo":"20051110115808.418125BF88@nox.op5.se","subject":"Re: [PATCH 1/2] git-clone: Keep remote names when cloning unless explicitly told not to.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-10T17:15:50Z","receivedAt":"2005-11-10T17:15:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"exon@op5.se (Andreas Ericsson) writes:\n\n> +\tThe name of a new directory to clone into.  The\t\"humanish\"\n> +\tpart of the source repository is used if no directory is\n> +\texplicitly given (\"repo\" for \"/path/to/repo.git\" and \"foo\"\n> +\tfor \"host.xz:foo/.git\").  Cloning into an existing directory\n> +\tis not allowed.\n>  \n> +# Try using \"humanish\" part of source repo if user didn't specify one\n> +[ -z \"$dir\" ] && dir=$(echo \"$repo\" | sed -e 's#/*\\.git$##' -e 's#.*[/:]##')\n\nMicronit; if I version control contents of my home directory on\nhost.xz [*1*] under git, I would say host.xz:.git/ when cloning\nit, wouldn't I?\n\nMaybe we would want to check if the resulting $dir makes sense\nafter this step.\n\n[Footnote]\n\n*1* ... I wouldn't personally, but some people are known to do\nthat.\n"},{"id":"11486","messageId":"43738818.4010906@op5.se","threadId":"2426","inReplyTo":"7vd5l81l15.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/2] git-clone: Keep remote names when cloning unless explicitly told not to.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2005-11-10T17:49:12Z","receivedAt":"2005-11-10T17:49:12Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> exon@op5.se (Andreas Ericsson) writes:\n> \n>>+# Try using \"humanish\" part of source repo if user didn't specify one\n>>+[ -z \"$dir\" ] && dir=$(echo \"$repo\" | sed -e 's#/*\\.git$##' -e 's#.*[/:]##')\n> \n> \n> Micronit; if I version control contents of my home directory on\n> host.xz [*1*] under git, I would say host.xz:.git/ when cloning\n> it, wouldn't I?\n> \n\nGah. Does anyone do that?\n\nAnyways,\n\tsed -e 's#:*/*\\.git$##' -e 's#.*[/:]##'\nwould turn that into \"host.xz\", so that should work real nice like, I \nsuppose.\n\n> Maybe we would want to check if the resulting $dir makes sense\n> after this step.\n> \n\nPerhaps, but this would lead to mkdir complaining about the empty \ndirectory name, so it's no worse than the current code. The sane user \nthen looks at the help output and determines that he needs to specify a \ntarget directory.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"}]}