All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clone: fix repo name when cloning a server's root
@ 2015-07-27 11:48 Patrick Steinhardt
  2015-07-27 12:51 ` Duy Nguyen
                   ` (4 more replies)
  0 siblings, 5 replies; 53+ messages in thread
From: Patrick Steinhardt @ 2015-07-27 11:48 UTC (permalink / raw)
  To: git; +Cc: peff, pclouds, ps

When cloning a repository from a server's root, that is the URL's
path component is a '/' only, we fail to generate a sensible
repository name when the URL contains authentication data. This
is especially bad when cloning URLs like
'ssh://user:passwd@example.com/', which results in a repository
'passwd@example.com' being created.

Improve the behavior by also regarding '@'-signs as a separator
when scanning the URL. In the mentioned case this would instead
result in a directory 'example.com' being created.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
I was not able to come by with a useful test as that would
require being able to clone a root directory. I couldn't find
anything in the current tests that looks like what I want to do.
Does anybody have an idea on how to achieve this?

 builtin/clone.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index a72ff7e..aaf38b2 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -164,11 +164,13 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
 
 	/*
 	 * Find last component, but be prepared that repo could have
-	 * the form  "remote.example.com:foo.git", i.e. no slash
-	 * in the directory part.
+	 * the form  "remote.example.com:foo.git", i.e. no slash in
+	 * the directory part, or "user:password@remote.example.com/",
+	 * that is the path component may be empty.
 	 */
 	start = end;
-	while (repo < start && !is_dir_sep(start[-1]) && start[-1] != ':')
+	while (repo < start && !is_dir_sep(start[-1]) && start[-1] != ':'
+			&& start[-1] != '@')
 		start--;
 
 	/*
-- 
2.4.6

^ permalink raw reply related	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2015-08-10 18:07 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-27 11:48 [PATCH] clone: fix repo name when cloning a server's root Patrick Steinhardt
2015-07-27 12:51 ` Duy Nguyen
2015-07-27 12:59   ` Patrick Steinhardt
2015-07-27 14:29   ` Junio C Hamano
2015-07-29 15:51 ` [PATCH v2 0/6] " Patrick Steinhardt
2015-07-29 15:51   ` [PATCH v2 1/6] tests: fix broken && chains in t1509-root-worktree Patrick Steinhardt
2015-07-29 15:51   ` [PATCH v2 2/6] tests: fix cleanup after tests " Patrick Steinhardt
2015-07-29 15:51   ` [PATCH v2 3/6] connect: expose parse_connect_url() Patrick Steinhardt
2015-07-29 15:51   ` [PATCH v2 4/6] connect: move error check to caller of parse_connect_url Patrick Steinhardt
2015-07-29 20:32     ` Eric Sunshine
2015-07-30 12:19       ` Patrick Steinhardt
2015-07-29 15:51   ` [PATCH v2 5/6] clone: fix hostname parsing when guessing dir Patrick Steinhardt
2015-07-29 17:42     ` Junio C Hamano
2015-07-30 12:18       ` Patrick Steinhardt
2015-07-30 16:30         ` Junio C Hamano
2015-07-30 16:53           ` Junio C Hamano
2015-08-03  8:34             ` Patrick Steinhardt
2015-08-03 16:37               ` Jeff King
2015-08-03 19:43                 ` Junio C Hamano
2015-07-29 15:51   ` [PATCH v2 6/6] clone: add tests for cloning with empty path Patrick Steinhardt
2015-07-30 18:18     ` Eric Sunshine
2015-07-31  0:58       ` Junio C Hamano
2015-07-31  8:45         ` Patrick Steinhardt
2015-08-04 11:29 ` [PATCH v3 0/6] fix repo name when cloning a server's root Patrick Steinhardt
2015-08-04 11:29   ` [PATCH v3 1/6] tests: fix broken && chains in t1509-root-worktree Patrick Steinhardt
2015-08-04 11:29   ` [PATCH v3 2/6] tests: fix cleanup after tests " Patrick Steinhardt
2015-08-04 11:29   ` [PATCH v3 3/6] clone: do not include authentication data in guessed dir Patrick Steinhardt
2015-08-04 11:29   ` [PATCH v3 4/6] clone: do not use port number as dir name Patrick Steinhardt
2015-08-04 11:29   ` [PATCH v3 5/6] clone: abort if no dir name could be guessed Patrick Steinhardt
2015-08-04 11:29   ` [PATCH v3 6/6] clone: add tests for cloning with empty path Patrick Steinhardt
2015-08-04 18:37     ` Eric Sunshine
2015-08-05 17:34   ` [PATCH v3 0/6] fix repo name when cloning a server's root Junio C Hamano
2015-08-05 21:19     ` Jeff King
2015-08-06  7:22       ` Torsten Bögershausen
2015-08-06  8:00         ` Junio C Hamano
2015-08-05 10:06 ` [PATCH v4 0/3] " Patrick Steinhardt
2015-08-05 10:06   ` [PATCH v4 1/3] clone: do not include authentication data in guessed dir Patrick Steinhardt
2015-08-05 17:43     ` Junio C Hamano
2015-08-05 19:36       ` Junio C Hamano
2015-08-05 19:41         ` Junio C Hamano
2015-08-06  9:47           ` Patrick Steinhardt
2015-08-07 20:45             ` Junio C Hamano
2015-08-08 17:37               ` Patrick Steinhardt
2015-08-05 10:06   ` [PATCH v4 2/3] clone: do not use port number as dir name Patrick Steinhardt
2015-08-05 10:06   ` [PATCH v4 3/3] clone: abort if no dir name could be guessed Patrick Steinhardt
2015-08-05 17:44     ` Junio C Hamano
2015-08-10 15:48 ` [PATCH v5 0/5] Improve guessing of repository names Patrick Steinhardt
2015-08-10 15:48   ` [PATCH v5 1/5] clone: add tests for output directory Patrick Steinhardt
2015-08-10 15:48   ` [PATCH v5 2/5] clone: use computed length in guess_dir_name Patrick Steinhardt
2015-08-10 15:48   ` [PATCH v5 3/5] clone: do not include authentication data in guessed dir Patrick Steinhardt
2015-08-10 15:48   ` [PATCH v5 4/5] clone: do not use port number as dir name Patrick Steinhardt
2015-08-10 15:48   ` [PATCH v5 5/5] clone: abort if no dir name could be guessed Patrick Steinhardt
2015-08-10 18:07   ` [PATCH v5 0/5] Improve guessing of repository names Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.