diff options
-rw-r--r-- | builtin/clone.c | 3 | ||||
-rwxr-xr-x | t/t2025-worktree-add.sh | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index 3e14491a34..69eabc0d88 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -423,7 +423,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 3694174989..8f3e726d35 100755 --- a/t/t2025-worktree-add.sh +++ b/t/t2025-worktree-add.sh @@ -198,4 +198,10 @@ 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_done |