summaryrefslogtreecommitdiff
path: root/builtin/clone.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2015-08-10 15:48:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-08-10 18:02:11 (GMT)
commitadef9561f0c8cf2c974d78adac0ae236e159e49f (patch)
treec915c91d374b3951d7ac138f56138aa9c34c7ba6 /builtin/clone.c
parent92722efec01f67a54b68c83fcbc3cd65f9fbb7b8 (diff)
downloadgit-adef9561f0c8cf2c974d78adac0ae236e159e49f.zip
git-adef9561f0c8cf2c974d78adac0ae236e159e49f.tar.gz
git-adef9561f0c8cf2c974d78adac0ae236e159e49f.tar.bz2
clone: abort if no dir name could be guessed
Due to various components of the URI being stripped off it may happen that we fail to guess a directory name. We currently error out with a message that it is impossible to create the working tree '' in such cases. Instead, error out early with a sensible error message hinting that a directory name should be specified manually on the command line. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/clone.c')
-rw-r--r--builtin/clone.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index c68eae1..f60d327 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -215,6 +215,10 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
len = end - start;
strip_suffix_mem(start, &len, is_bundle ? ".bundle" : ".git");
+ if (!len || (len == 1 && *start == '/'))
+ die("No directory name could be guessed.\n"
+ "Please specify a directory on the command line");
+
if (is_bare)
dir = xstrfmt("%.*s.git", (int)len, start);
else