Merge branch 'bc/maint-daemon-sans-ss-family'
[git/mjg.git] / t / t5502-quickfetch.sh
blob1037a723fe74756f241346a077f4f3682dbbf45d
1 #!/bin/sh
3 test_description='test quickfetch from local'
5 . ./test-lib.sh
7 test_expect_success setup '
9 test_tick &&
10 echo ichi >file &&
11 git add file &&
12 git commit -m initial &&
14 cnt=$( (
15 git count-objects | sed -e "s/ *objects,.*//"
16 ) ) &&
17 test $cnt -eq 3
20 test_expect_success 'clone without alternate' '
23 mkdir cloned &&
24 cd cloned &&
25 git init-db &&
26 git remote add -f origin ..
27 ) &&
28 cnt=$( (
29 cd cloned &&
30 git count-objects | sed -e "s/ *objects,.*//"
31 ) ) &&
32 test $cnt -eq 3
35 test_expect_success 'further commits in the original' '
37 test_tick &&
38 echo ni >file &&
39 git commit -a -m second &&
41 cnt=$( (
42 git count-objects | sed -e "s/ *objects,.*//"
43 ) ) &&
44 test $cnt -eq 6
47 test_expect_success 'copy commit and tree but not blob by hand' '
49 git rev-list --objects HEAD |
50 git pack-objects --stdout |
52 cd cloned &&
53 git unpack-objects
54 ) &&
56 cnt=$( (
57 cd cloned &&
58 git count-objects | sed -e "s/ *objects,.*//"
59 ) ) &&
60 test $cnt -eq 6
62 blob=$(git rev-parse HEAD:file | sed -e "s|..|&/|") &&
63 test -f "cloned/.git/objects/$blob" &&
64 rm -f "cloned/.git/objects/$blob" &&
66 cnt=$( (
67 cd cloned &&
68 git count-objects | sed -e "s/ *objects,.*//"
69 ) ) &&
70 test $cnt -eq 5
74 test_expect_success 'quickfetch should not leave a corrupted repository' '
77 cd cloned &&
78 git fetch
79 ) &&
81 cnt=$( (
82 cd cloned &&
83 git count-objects | sed -e "s/ *objects,.*//"
84 ) ) &&
85 test $cnt -eq 6
89 test_expect_success 'quickfetch should not copy from alternate' '
92 mkdir quickclone &&
93 cd quickclone &&
94 git init-db &&
95 (cd ../.git/objects && pwd) >.git/objects/info/alternates &&
96 git remote add origin .. &&
97 git fetch -k -k
98 ) &&
99 obj_cnt=$( (
100 cd quickclone &&
101 git count-objects | sed -e "s/ *objects,.*//"
102 ) ) &&
103 pck_cnt=$( (
104 cd quickclone &&
105 git count-objects -v | sed -n -e "/packs:/{
106 s/packs://
110 ) ) &&
111 origin_master=$( (
112 cd quickclone &&
113 git rev-parse origin/master
114 ) ) &&
115 echo "loose objects: $obj_cnt, packfiles: $pck_cnt" &&
116 test $obj_cnt -eq 0 &&
117 test $pck_cnt -eq 0 &&
118 test z$origin_master = z$(git rev-parse master)
122 test_expect_success 'quickfetch should handle ~1000 refs (on Windows)' '
124 git gc &&
125 head=$(git rev-parse HEAD) &&
126 branchprefix="$head refs/heads/branch" &&
127 for i in 0 1 2 3 4 5 6 7 8 9; do
128 for j in 0 1 2 3 4 5 6 7 8 9; do
129 for k in 0 1 2 3 4 5 6 7 8 9; do
130 echo "$branchprefix$i$j$k" >> .git/packed-refs
131 done
132 done
133 done &&
135 cd cloned &&
136 git fetch &&
137 git fetch
142 test_done