Merge branch 'es/clone-shared-worktree'
authorJunio C Hamano <gitster@pobox.com>
Wed, 27 Dec 2017 19:16:28 +0000 (11:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Dec 2017 19:16:28 +0000 (11:16 -0800)
"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

builtin/clone.c
t/t2025-worktree-add.sh
index b22845738afe68e61d45883e89a470213de921ef..6ad0ab3fa40af1761482f5fc78b4b1c401f9717c 100644 (file)
@@ -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 {
index 1285668cfce0bb0f9f7a62dcf3dd293d03be40b2..2b959449730e14dd4e650ce9115a463d71eedca4 100755 (executable)
@@ -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 &&