Skip to content

Commit 237aa99

Browse files
committed
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
2 parents e2e2bf2 + b3b0597 commit 237aa99

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

builtin/clone.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ static void clone_local(const char *src_repo, const char *dest_repo)
452452
{
453453
if (option_shared) {
454454
struct strbuf alt = STRBUF_INIT;
455-
strbuf_addf(&alt, "%s/objects", src_repo);
455+
get_common_dir(&alt, src_repo);
456+
strbuf_addstr(&alt, "/objects");
456457
add_to_alternates_file(alt.buf);
457458
strbuf_release(&alt);
458459
} else {

t/t2025-worktree-add.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ test_expect_success 'local clone from linked checkout' '
245245
( cd here-clone && git fsck )
246246
'
247247

248+
test_expect_success 'local clone --shared from linked checkout' '
249+
git -C bare worktree add --detach ../baretree &&
250+
git clone --local --shared baretree bare-clone &&
251+
grep /bare/ bare-clone/.git/objects/info/alternates
252+
'
253+
248254
test_expect_success '"add" worktree with --no-checkout' '
249255
git worktree add --no-checkout -b swamp swamp &&
250256
! test -e swamp/init.t &&

0 commit comments

Comments
 (0)