@matheusbsbs / matheus-bagliano / commits / 0879aa2870
Fork 0

git-clone: Keep remote names when cloning unless explicitly told not to.

With this patch the following commands all clone into the local directory "repo". If repo exists, it will still barf. git-clone git://host.xz/repo.git git-clone /path/to/repo/.git git-clone host.xz:repo.git I ended up doing the same source-to-target sed'ing for all our company projects, so it was easier to add it directly to git-clone. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Junio C Hamano <junkio@cox.net>

Andreas Ericsson committed Nov 10, 2005 at 12:58 UTC 0879aa28708dcdfa255fff631781e5178755498e
2 files changed +9 -5
Documentation/git-clone.txt
+7 -5
@@ -8,7 +8,7 @@ git-clone - Clones a repository.
8
9 SYNOPSIS
10 --------
11 -'git-clone' [-l [-s]] [-q] [-n] [-u <upload-pack>] <repository> <directory>
11 +'git-clone' [-l [-s]] [-q] [-n] [-u <upload-pack>] <repository> [<directory>]
12
13 DESCRIPTION
14 -----------
@@ -68,9 +68,11 @@ OPTIONS
68 be any URL git-fetch supports.
69
70 <directory>::
71 - The name of a new directory to be cloned into. It is an
72 - error to specify an existing directory.
73 -
71 + The name of a new directory to clone into. The "humanish"
72 + part of the source repository is used if no directory is
73 + explicitly given ("repo" for "/path/to/repo.git" and "foo"
74 + for "host.xz:foo/.git"). Cloning into an existing directory
75 + is not allowed.
76
77 Author
78 ------
@@ -78,7 +80,7 @@ Written by Linus Torvalds <torvalds@osdl.org>
80
81 Documentation
82 --------------
81 -Documentation by Junio C Hamano.
83 +Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
84
85
86 GIT
git-clone.sh
+2
@@ -96,6 +96,8 @@ if base=$(get_repo_base "$repo"); then
96 fi
97
98 dir="$2"
99 +# Try using "humanish" part of source repo if user didn't specify one
100 +[ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*/||g')
101 mkdir "$dir" &&
102 D=$(
103 (cd "$dir" && git-init-db && pwd)