]>
Commit | Line | Data |
---|---|---|
6b17c674 JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Johannes Schindelin | |
4 | # | |
5 | ||
6 | test_description='Testing multi_ack pack fetching | |
7 | ||
8 | ' | |
9 | . ./test-lib.sh | |
10 | ||
11 | # Test fetch-pack/upload-pack pair. | |
12 | ||
13 | # Some convenience functions | |
14 | ||
1010437d EW |
15 | add () { |
16 | name=$1 | |
17 | text="$@" | |
18 | branch=`echo $name | sed -e 's/^\(.\).*$/\1/'` | |
19 | parents="" | |
6b17c674 JS |
20 | |
21 | shift | |
22 | while test $1; do | |
23 | parents="$parents -p $1" | |
24 | shift | |
25 | done | |
26 | ||
27 | echo "$text" > test.txt | |
5be60078 JH |
28 | git update-index --add test.txt |
29 | tree=$(git write-tree) | |
6b17c674 JS |
30 | # make sure timestamps are in correct order |
31 | sec=$(($sec+1)) | |
32 | commit=$(echo "$text" | GIT_AUTHOR_DATE=$sec \ | |
5be60078 | 33 | git commit-tree $tree $parents 2>>log2.txt) |
0e46e704 | 34 | eval "$name=$commit; export $name" |
6b17c674 JS |
35 | echo $commit > .git/refs/heads/$branch |
36 | eval ${branch}TIP=$commit | |
37 | } | |
38 | ||
1010437d | 39 | count_objects () { |
6b17c674 JS |
40 | ls .git/objects/??/* 2>>log2.txt | wc -l | tr -d " " |
41 | } | |
42 | ||
1010437d EW |
43 | test_expect_object_count () { |
44 | message=$1 | |
45 | count=$2 | |
6b17c674 JS |
46 | |
47 | output="$(count_objects)" | |
48 | test_expect_success \ | |
49 | "new object count $message" \ | |
50 | "test $count = $output" | |
51 | } | |
52 | ||
1010437d EW |
53 | pull_to_client () { |
54 | number=$1 | |
55 | heads=$2 | |
56 | count=$3 | |
57 | no_strict_count_check=$4 | |
6b17c674 JS |
58 | |
59 | cd client | |
60 | test_expect_success "$number pull" \ | |
7f732c63 | 61 | "git-fetch-pack -k -v .. $heads" |
6b17c674 JS |
62 | case "$heads" in *A*) echo $ATIP > .git/refs/heads/A;; esac |
63 | case "$heads" in *B*) echo $BTIP > .git/refs/heads/B;; esac | |
5be60078 | 64 | git symbolic-ref HEAD refs/heads/`echo $heads | sed -e 's/^\(.\).*$/\1/'` |
7f732c63 | 65 | |
5be60078 | 66 | test_expect_success "fsck" 'git fsck --full > fsck.txt 2>&1' |
7f732c63 JH |
67 | |
68 | test_expect_success 'check downloaded results' \ | |
69 | 'mv .git/objects/pack/pack-* . && | |
70 | p=`ls -1 pack-*.pack` && | |
5be60078 JH |
71 | git unpack-objects <$p && |
72 | git fsck --full' | |
7f732c63 JH |
73 | |
74 | test_expect_success "new object count after $number pull" \ | |
75 | 'idx=`echo pack-*.idx` && | |
5be60078 | 76 | pack_count=`git show-index <$idx | wc -l` && |
7f732c63 | 77 | test $pack_count = $count' |
6b17c674 JS |
78 | test -z "$pack_count" && pack_count=0 |
79 | if [ -z "$no_strict_count_check" ]; then | |
80 | test_expect_success "minimal count" "test $count = $pack_count" | |
81 | else | |
82 | test $count != $pack_count && \ | |
83 | echo "WARNING: $pack_count objects transmitted, only $count of which were needed" | |
84 | fi | |
7f732c63 | 85 | rm -f pack-* |
6b17c674 JS |
86 | cd .. |
87 | } | |
88 | ||
89 | # Here begins the actual testing | |
90 | ||
91 | # A1 - ... - A20 - A21 | |
92 | # \ | |
93 | # B1 - B2 - .. - B70 | |
94 | ||
95 | # client pulls A20, B1. Then tracks only B. Then pulls A. | |
96 | ||
97 | ( | |
98 | mkdir client && | |
99 | cd client && | |
5be60078 | 100 | git init 2>> log2.txt && |
e0d10e1c | 101 | git config transfer.unpacklimit 0 |
6b17c674 JS |
102 | ) |
103 | ||
104 | add A1 | |
105 | ||
106 | prev=1; cur=2; while [ $cur -le 10 ]; do | |
107 | add A$cur $(eval echo \$A$prev) | |
108 | prev=$cur | |
109 | cur=$(($cur+1)) | |
110 | done | |
111 | ||
112 | add B1 $A1 | |
113 | ||
114 | echo $ATIP > .git/refs/heads/A | |
115 | echo $BTIP > .git/refs/heads/B | |
5be60078 | 116 | git symbolic-ref HEAD refs/heads/B |
6b17c674 JS |
117 | |
118 | pull_to_client 1st "B A" $((11*3)) | |
119 | ||
6b17c674 JS |
120 | add A11 $A10 |
121 | ||
122 | prev=1; cur=2; while [ $cur -le 65 ]; do | |
123 | add B$cur $(eval echo \$B$prev) | |
124 | prev=$cur | |
125 | cur=$(($cur+1)) | |
126 | done | |
127 | ||
128 | pull_to_client 2nd "B" $((64*3)) | |
129 | ||
6b17c674 JS |
130 | pull_to_client 3rd "A" $((1*3)) # old fails |
131 | ||
f69e836f | 132 | test_expect_success "clone shallow" 'git-clone --depth 2 "file://$(pwd)/." shallow' |
16ad3579 | 133 | |
5be60078 | 134 | (cd shallow; git count-objects -v) > count.shallow |
16ad3579 JS |
135 | |
136 | test_expect_success "clone shallow object count" \ | |
137 | "test \"in-pack: 18\" = \"$(grep in-pack count.shallow)\"" | |
138 | ||
37818d7d JH |
139 | count_output () { |
140 | sed -e '/^in-pack:/d' -e '/^packs:/d' -e '/: 0$/d' "$1" | |
141 | } | |
142 | ||
143 | test_expect_success "clone shallow object count (part 2)" ' | |
144 | test -z "$(count_output count.shallow)" | |
145 | ' | |
16ad3579 JS |
146 | |
147 | test_expect_success "fsck in shallow repo" \ | |
5be60078 | 148 | "(cd shallow; git fsck --full)" |
16ad3579 JS |
149 | |
150 | #test_done; exit | |
151 | ||
152 | add B66 $B65 | |
153 | add B67 $B66 | |
154 | ||
155 | test_expect_success "pull in shallow repo" \ | |
156 | "(cd shallow; git pull .. B)" | |
157 | ||
5be60078 | 158 | (cd shallow; git count-objects -v) > count.shallow |
16ad3579 JS |
159 | test_expect_success "clone shallow object count" \ |
160 | "test \"count: 6\" = \"$(grep count count.shallow)\"" | |
161 | ||
162 | add B68 $B67 | |
163 | add B69 $B68 | |
164 | ||
165 | test_expect_success "deepening pull in shallow repo" \ | |
166 | "(cd shallow; git pull --depth 4 .. B)" | |
167 | ||
5be60078 | 168 | (cd shallow; git count-objects -v) > count.shallow |
16ad3579 JS |
169 | test_expect_success "clone shallow object count" \ |
170 | "test \"count: 12\" = \"$(grep count count.shallow)\"" | |
171 | ||
172 | test_expect_success "deepening fetch in shallow repo" \ | |
173 | "(cd shallow; git fetch --depth 4 .. A:A)" | |
174 | ||
5be60078 | 175 | (cd shallow; git count-objects -v) > count.shallow |
16ad3579 JS |
176 | test_expect_success "clone shallow object count" \ |
177 | "test \"count: 18\" = \"$(grep count count.shallow)\"" | |
178 | ||
41ac414e | 179 | test_expect_success "pull in shallow repo with missing merge base" \ |
d492b31c | 180 | "(cd shallow && test_must_fail git pull --depth 4 .. A)" |
16ad3579 | 181 | |
6b17c674 | 182 | test_done |