[PATCH v5 5/5] clone: abort if no dir name could be guessed
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 10, 2015, 15:48 UTC
- Message-ID
- <1439221705-20336-6-git-send-email-ps@pks.im>
- In-Reply-To
- <1439221705-20336-1-git-send-email-ps@pks.im>
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> --- builtin/clone.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/builtin/clone.c b/builtin/clone.c index e7f16ff..5169746 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
-- 2.5.0