diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-11-05 23:18:07 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-11-05 23:18:08 +0300 |
commit | 4349f597f08b6dc50fc6198b8e1b96e19df37c65 (patch) | |
tree | cda184215e2f3e14bb4d9871af0df367ea0ea01f /builtin | |
parent | 53be145209eeac5972d4ea4374d667fdf594f78f (diff) | |
parent | d78db8424ec5c3f3327441cd1a897064af39da91 (diff) |
Merge branch 'nd/clone-linked-checkout' into maint
It was not possible to use a repository-lookalike created by "git
worktree add" as a local source of "git clone".
* nd/clone-linked-checkout:
clone: better error when --reference is a linked checkout
clone: allow --local from a linked checkout
enter_repo: allow .git files in strict mode
enter_repo: avoid duplicating logic, use is_git_directory() instead
t0002: add test for enter_repo(), non-strict mode
path.c: delete an extra space
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/clone.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index cc896e22d1..9eaecd9a7c 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -294,9 +294,14 @@ static int add_one_reference(struct string_list_item *item, void *cb_data) char *ref_git_git = mkpathdup("%s/.git", ref_git); free(ref_git); ref_git = ref_git_git; - } else if (!is_directory(mkpath("%s/objects", ref_git))) + } else if (!is_directory(mkpath("%s/objects", ref_git))) { + struct strbuf sb = STRBUF_INIT; + if (get_common_dir(&sb, ref_git)) + die(_("reference repository '%s' as a linked checkout is not supported yet."), + item->string); die(_("reference repository '%s' is not a local repository."), item->string); + } if (!access(mkpath("%s/shallow", ref_git), F_OK)) die(_("reference repository '%s' is shallow"), item->string); @@ -424,8 +429,10 @@ static void clone_local(const char *src_repo, const char *dest_repo) } else { struct strbuf src = STRBUF_INIT; struct strbuf dest = STRBUF_INIT; - strbuf_addf(&src, "%s/objects", src_repo); - strbuf_addf(&dest, "%s/objects", dest_repo); + get_common_dir(&src, src_repo); + get_common_dir(&dest, dest_repo); + strbuf_addstr(&src, "/objects"); + strbuf_addstr(&dest, "/objects"); copy_or_link_directory(&src, &dest, src_repo, src.len); strbuf_release(&src); strbuf_release(&dest); |