Skip to content

Commit

Permalink
clone: abort if no dir name could be guessed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Patrick Steinhardt authored and Junio C Hamano committed Aug 10, 2015
1 parent 92722ef commit adef956
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit adef956

Please sign in to comment.