diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2008-08-01 16:01:36 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-08-03 14:05:55 -0700 |
commit | 6612f877cc94e80cd0c7393a8ea6bfea69146b3c (patch) | |
tree | 936a286e2ffaf1c2a608f2f63d5adf657aeb74c3 /builtin-clone.c | |
parent | 807d86945336f676c9f650a6cbae9baa3191aaec (diff) | |
download | git-6612f877cc94e80cd0c7393a8ea6bfea69146b3c.tar.gz |
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-clone.c')
-rw-r--r-- | builtin-clone.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin-clone.c b/builtin-clone.c index ecdcefa2a6..8612d59dd2 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); |