Skip to content

Commit 744e469

Browse files
pcloudsgitster
authored andcommitted
clone: allow --local from a linked checkout
Noticed-by: Bjørnar Snoksrud <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1f5fbe1 commit 744e469

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

builtin/clone.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,10 @@ static void clone_local(const char *src_repo, const char *dest_repo)
424424
} else {
425425
struct strbuf src = STRBUF_INIT;
426426
struct strbuf dest = STRBUF_INIT;
427-
strbuf_addf(&src, "%s/objects", src_repo);
428-
strbuf_addf(&dest, "%s/objects", dest_repo);
427+
get_common_dir(&src, src_repo);
428+
get_common_dir(&dest, dest_repo);
429+
strbuf_addstr(&src, "/objects");
430+
strbuf_addstr(&dest, "/objects");
429431
copy_or_link_directory(&src, &dest, src_repo, src.len);
430432
strbuf_release(&src);
431433
strbuf_release(&dest);

t/t2025-worktree-add.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,9 @@ test_expect_success '"add" -B/--detach mutually exclusive' '
193193
test_must_fail git worktree add -B poodle --detach bamboo master
194194
'
195195

196+
test_expect_success 'local clone from linked checkout' '
197+
git clone --local here here-clone &&
198+
( cd here-clone && git fsck )
199+
'
200+
196201
test_done

0 commit comments

Comments
 (0)