summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 807d869)
raw | patch | inline | side by side (parent: 807d869)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Fri, 1 Aug 2008 14:01:36 +0000 (16:01 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 3 Aug 2008 21:05:55 +0000 (14:05 -0700) |
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>
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>
builtin-clone.c | patch | blob | history | |
t/t5601-clone.sh | patch | blob | history |
diff --git a/builtin-clone.c b/builtin-clone.c
index ecdcefa2a6901a8c8eb0902845e40fea216d7249..8612d59dd22202bc8af3436bffcade2e2dba5fcf 100644 (file)
--- a/builtin-clone.c
+++ b/builtin-clone.c
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;
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);
}
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 a5334570ad4e944ac7c95e9b6c41bb96cb475c0c..57173b4c50ec5f30198c9bf8bd8d03edd17bb235 100755 (executable)
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
'
+test_expect_success 'clone --bare names the local repository <name>.git' '
+
+ git clone --bare src &&
+ test -d src.git
+
+'
+
test_done