summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: db3a954)
raw | patch | inline | side by side (parent: db3a954)
author | Clemens Buchacher <drizzd@aon.at> | |
Wed, 3 Sep 2008 18:55:55 +0000 (20:55 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 3 Sep 2008 19:32:41 +0000 (12:32 -0700) |
'git clone <repo> path/' (note the trailing slash) fails, because the
entire path is interpreted as leading directories. So when mkdir tries to
create the actual path, it already exists.
This makes sure trailing slashes are removed.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
entire path is interpreted as leading directories. So when mkdir tries to
create the actual path, it already exists.
This makes sure trailing slashes are removed.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
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 f44eceab3a31ba38baaa5cbec366e69a989183d2..c8435295cedd920f34a13ec686c73d6b835b28ee 100644 (file)
--- a/builtin-clone.c
+++ b/builtin-clone.c
return !stat(path, &buf) && S_ISDIR(buf.st_mode);
}
+static void strip_trailing_slashes(char *dir)
+{
+ char *end = dir + strlen(dir);
+
+ while (dir < end - 1 && is_dir_sep(end[-1]))
+ end--;
+ *end = '\0';
+}
+
static void setup_reference(const char *repo)
{
const char *ref_git;
dir = xstrdup(argv[1]);
else
dir = guess_dir_name(repo_name, is_bundle, option_bare);
+ strip_trailing_slashes(dir);
if (!stat(dir, &buf))
die("destination directory '%s' already exists.", dir);
if (!option_bare) {
junk_work_tree = work_tree;
if (safe_create_leading_directories_const(work_tree) < 0)
- die("could not create leading directories of '%s'",
- work_tree);
+ die("could not create leading directories of '%s': %s",
+ work_tree, strerror(errno));
if (mkdir(work_tree, 0755))
- die("could not create work tree dir '%s'.", work_tree);
+ die("could not create work tree dir '%s': %s.",
+ work_tree, strerror(errno));
set_git_work_tree(work_tree);
}
junk_git_dir = git_dir;
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 59c65fef286ad8d52a15c942f6975607f0347f66..78a3fa639c97b7dce054d89c74c67a855d0d7954 100755 (executable)
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
'
+test_expect_success 'clone to destination with trailing /' '
+
+ git clone src target-1/ &&
+ T=$( cd target-1 && git rev-parse HEAD ) &&
+ S=$( cd src && git rev-parse HEAD ) &&
+ test "$T" = "$S"
+
+'
+
+test_expect_success 'clone to destination with extra trailing /' '
+
+ git clone src target-2/// &&
+ T=$( cd target-2 && git rev-parse HEAD ) &&
+ S=$( cd src && git rev-parse HEAD ) &&
+ test "$T" = "$S"
+
+'
+
test_done