3 test_description
='test quickfetch from local'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success setup
'
16 git commit -m initial &&
19 git count-objects | sed -e "s/ *objects,.*//"
24 test_expect_success
'clone without alternate' '
30 git remote add -f origin ..
34 git count-objects | sed -e "s/ *objects,.*//"
39 test_expect_success
'further commits in the original' '
43 git commit -a -m second &&
46 git count-objects | sed -e "s/ *objects,.*//"
51 test_expect_success
'copy commit and tree but not blob by hand' '
53 git rev-list --objects HEAD |
54 git pack-objects --stdout |
62 git count-objects | sed -e "s/ *objects,.*//"
66 blob=$(git rev-parse HEAD:file | sed -e "s|..|&/|") &&
67 test -f "cloned/.git/objects/$blob" &&
68 rm -f "cloned/.git/objects/$blob" &&
72 git count-objects | sed -e "s/ *objects,.*//"
78 test_expect_success
'quickfetch should not leave a corrupted repository' '
87 git count-objects | sed -e "s/ *objects,.*//"
93 test_expect_success
'quickfetch should not copy from alternate' '
99 (cd ../.git/objects && pwd) >.git/objects/info/alternates &&
100 git remote add origin .. &&
105 git count-objects | sed -e "s/ *objects,.*//"
109 git count-objects -v | sed -n -e "/packs:/{
117 git rev-parse origin/main
119 echo "loose objects: $obj_cnt, packfiles: $pck_cnt" &&
120 test $obj_cnt -eq 0 &&
121 test $pck_cnt -eq 0 &&
122 test z$origin_main = z$(git rev-parse main)
126 test_expect_success
'quickfetch should handle ~1000 refs (on Windows)' '
129 head=$(git rev-parse HEAD) &&
130 branchprefix="$head refs/heads/branch" &&
131 for i in 0 1 2 3 4 5 6 7 8 9; do
132 for j in 0 1 2 3 4 5 6 7 8 9; do
133 for k in 0 1 2 3 4 5 6 7 8 9; do
134 echo "$branchprefix$i$j$k" >> .git/packed-refs || return 1