summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 13d6ec9)
raw | patch | inline | side by side (parent: 13d6ec9)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Sun, 21 Aug 2011 11:58:09 +0000 (18:58 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 22 Aug 2011 21:20:11 +0000 (14:20 -0700) |
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 f579794d9a93a0e55289921f20b8f68b85211ca1..ec57f3dbe4a629b502f7c9e60f89244ef446af4f 100644 (file)
--- a/builtin/clone.c
+++ b/builtin/clone.c
for (i = 0; i < ARRAY_SIZE(suffix); i++) {
const char *path;
path = mkpath("%s%s", repo, suffix[i]);
- if (is_directory(path)) {
+ if (stat(path, &st))
+ continue;
+ if (S_ISDIR(st.st_mode)) {
*is_bundle = 0;
return xstrdup(absolute_path(path));
+ } else if (S_ISREG(st.st_mode) && st.st_size > 8) {
+ /* Is it a "gitfile"? */
+ char signature[8];
+ int len, fd = open(path, O_RDONLY);
+ if (fd < 0)
+ continue;
+ len = read_in_full(fd, signature, 8);
+ close(fd);
+ if (len != 8 || strncmp(signature, "gitdir: ", 8))
+ continue;
+ path = read_gitfile(path);
+ if (path) {
+ *is_bundle = 0;
+ return xstrdup(absolute_path(path));
+ }
}
}
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 151ea531bdfeb5a012e57407749beb4f26de6d2a..501bd3fb6cc9c8795a0ea9570512668abaaa2693 100755 (executable)
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
test_cmp expected dst/.git
'
+test_expect_success 'clone from .git file' '
+ git clone dst/.git dst2
+'
+
test_expect_success 'clone separate gitdir where target already exists' '
rm -rf dst &&
test_must_fail git clone --separate-git-dir realgitdir src dst