summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-12-27 11:16:28 -0800
committerJunio C Hamano <gitster@pobox.com>2017-12-27 11:16:28 -0800
commit237aa99cd26da4daf9b2e75914ae17ecc9051f0c (patch)
tree89c37b586c70c52c12343d35c0655fc699b4da5f
parente2e2bf2450f96407976ac435489fd86b70728e3f (diff)
parentb3b05971c1e51bb991c768fb8cead2c0501fa93e (diff)
downloadgit-237aa99cd26da4daf9b2e75914ae17ecc9051f0c.tar.gz
Merge branch 'es/clone-shared-worktree'
"git clone --shared" to borrow from a (secondary) worktree did not work, even though "git clone --local" did. Both are now accepted. * es/clone-shared-worktree: clone: support 'clone --shared' from a worktree
-rw-r--r--builtin/clone.c3
-rwxr-xr-xt/t2025-worktree-add.sh6
2 files changed, 8 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index b22845738a..6ad0ab3fa4 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -452,7 +452,8 @@ static void clone_local(const char *src_repo, const char *dest_repo)
{
if (option_shared) {
struct strbuf alt = STRBUF_INIT;
- strbuf_addf(&alt, "%s/objects", src_repo);
+ get_common_dir(&alt, src_repo);
+ strbuf_addstr(&alt, "/objects");
add_to_alternates_file(alt.buf);
strbuf_release(&alt);
} else {
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index 1285668cfc..2b95944973 100755
--- a/t/t2025-worktree-add.sh
+++ b/t/t2025-worktree-add.sh
@@ -245,6 +245,12 @@ test_expect_success 'local clone from linked checkout' '
( cd here-clone && git fsck )
'
+test_expect_success 'local clone --shared from linked checkout' '
+ git -C bare worktree add --detach ../baretree &&
+ git clone --local --shared baretree bare-clone &&
+ grep /bare/ bare-clone/.git/objects/info/alternates
+'
+
test_expect_success '"add" worktree with --no-checkout' '
git worktree add --no-checkout -b swamp swamp &&
! test -e swamp/init.t &&