diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-09-23 14:21:39 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-09-23 14:21:39 -0700 |
commit | 406c1c4dd4a8f0fac3fddce1e7bb3b66af835e6a (patch) | |
tree | fdf9a1740fb73a40c0aee0f23d79792ea171f289 /builtin | |
parent | be5acb3b63af077db05788235a1d845d511e4561 (diff) | |
parent | 9b0ebc722cfc12bd14934aab5cf77ebe654e36e6 (diff) | |
download | git-406c1c4dd4a8f0fac3fddce1e7bb3b66af835e6a.tar.gz |
Merge branch 'nd/maint-clone-gitdir' into maint
* nd/maint-clone-gitdir:
clone: allow to clone from .git file
read_gitfile_gently(): rename misnamed function to read_gitfile()
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/clone.c | 19 | ||||
-rw-r--r-- | builtin/init-db.c | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index f579794d9a..ec57f3dbe4 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -101,9 +101,26 @@ static char *get_repo_path(const char *repo, int *is_bundle) 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/builtin/init-db.c b/builtin/init-db.c index 025aa47c80..d07554c884 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -347,7 +347,7 @@ static void separate_git_dir(const char *git_dir) const char *src; if (S_ISREG(st.st_mode)) - src = read_gitfile_gently(git_link); + src = read_gitfile(git_link); else if (S_ISDIR(st.st_mode)) src = git_link; else |