From: Johannes Schindelin Date: Fri, 1 Aug 2008 14:01:36 +0000 (+0200) Subject: clone --bare: Add ".git" suffix to the directory name to clone into X-Git-Tag: v1.6.0-rc2~32 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6612f877cc94e80cd0c7393a8ea6bfea69146b3c;p=git.git clone --bare: Add ".git" suffix to the directory name to clone into We have a tradition that bare repositories live in directories ending in ".git". To make this more a convention than just a tradition, teach "git clone --bare" to add a ".git" suffix to the directory name. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff --git a/builtin-clone.c b/builtin-clone.c index ecdcefa2a..8612d59dd 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -95,7 +95,7 @@ static char *get_repo_path(const char *repo, int *is_bundle) return NULL; } -static char *guess_dir_name(const char *repo, int is_bundle) +static char *guess_dir_name(const char *repo, int is_bundle, int is_bare) { const char *end = repo + strlen(repo), *start; @@ -131,6 +131,12 @@ static char *guess_dir_name(const char *repo, int is_bundle) end -= 4; } + if (is_bare) { + char *result = xmalloc(end - start + 5); + sprintf(result, "%.*s.git", (int)(end - start), start); + return result; + } + return xstrndup(start, end - start); } @@ -389,7 +395,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (argc == 2) dir = xstrdup(argv[1]); else - dir = guess_dir_name(repo_name, is_bundle); + dir = guess_dir_name(repo_name, is_bundle, option_bare); if (!stat(dir, &buf)) die("destination directory '%s' already exists.", dir); diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index a5334570a..57173b4c5 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -82,4 +82,11 @@ test_expect_success 'clone --mirror' ' ' +test_expect_success 'clone --bare names the local repository .git' ' + + git clone --bare src && + test -d src.git + +' + test_done