clone: allow --local from a linked checkout
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Mon, 28 Sep 2015 13:06:15 +0000 (20:06 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Sep 2015 17:46:35 +0000 (10:46 -0700)
Noticed-by: Bjørnar Snoksrud <snoksrud@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clone.c
t/t2025-worktree-add.sh
index 578da85254418a620d3c7c847af8eed6a3a29d58..39d4adf7d10e46647b890575a4b45a2ca435b47f 100644 (file)
@@ -424,8 +424,10 @@ static void clone_local(const char *src_repo, const char *dest_repo)
        } else {
                struct strbuf src = STRBUF_INIT;
                struct strbuf dest = STRBUF_INIT;
-               strbuf_addf(&src, "%s/objects", src_repo);
-               strbuf_addf(&dest, "%s/objects", dest_repo);
+               get_common_dir(&src, src_repo);
+               get_common_dir(&dest, dest_repo);
+               strbuf_addstr(&src, "/objects");
+               strbuf_addstr(&dest, "/objects");
                copy_or_link_directory(&src, &dest, src_repo, src.len);
                strbuf_release(&src);
                strbuf_release(&dest);
index 8267411a0ec129a67cde5381cfd79824471d8fd2..369417498946fcebb901d8593bb584f3767b1e67 100755 (executable)
@@ -193,4 +193,9 @@ test_expect_success '"add" -B/--detach mutually exclusive' '
        test_must_fail git worktree add -B poodle --detach bamboo master
 '
 
+test_expect_success 'local clone from linked checkout' '
+       git clone --local here here-clone &&
+       ( cd here-clone && git fsck )
+'
+
 test_done