Skip to content

Commit adef956

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 92722ef commit adef956

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

builtin/clone.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
215215
len = end - start;
216216
strip_suffix_mem(start, &len, is_bundle ? ".bundle" : ".git");
217217

218+
if (!len || (len == 1 && *start == '/'))
219+
die("No directory name could be guessed.\n"
220+
"Please specify a directory on the command line");
221+
218222
if (is_bare)
219223
dir = xstrfmt("%.*s.git", (int)len, start);
220224
else

0 commit comments

Comments
 (0)