@matheusbsbs / matheus-bagliano / commits / ac527b0b7c
Fork 0

[PATCH] add test for OFS_DELTA objects

Make sure pack-objects with --delta-base-offset works fine, and that it actually produces smaller packs as expected. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Nicolas Pitre committed Mar 16, 2007 at 13:50 UTC ac527b0b7c9be37ad7f2f7d871b6e9b41fd0c431
1 file changed +65 -6
t/t5300-pack-object.sh
+65 -6
@@ -64,7 +64,7 @@ test_expect_success \
64 cd "$TRASH"
65
66 test_expect_success \
67 - 'pack with delta' \
67 + 'pack with REF_DELTA' \
68 'pwd &&
69 packname_2=$(git-pack-objects test-2 <obj-list)'
70
@@ -72,7 +72,7 @@ rm -fr .git2
72 mkdir .git2
73
74 test_expect_success \
75 - 'unpack with delta' \
75 + 'unpack with REF_DELTA' \
76 'GIT_OBJECT_DIRECTORY=.git2/objects &&
77 export GIT_OBJECT_DIRECTORY &&
78 git-init &&
@@ -82,7 +82,7 @@ test_expect_success \
82 unset GIT_OBJECT_DIRECTORY
83 cd "$TRASH/.git2"
84 test_expect_success \
85 - 'check unpack with delta' \
85 + 'check unpack with REF_DELTA' \
86 '(cd ../.git && find objects -type f -print) |
87 while read path
88 do
@@ -93,6 +93,42 @@ test_expect_success \
93 done'
94 cd "$TRASH"
95
96 +test_expect_success \
97 + 'pack with OFS_DELTA' \
98 + 'pwd &&
99 + packname_3=$(git-pack-objects --delta-base-offset test-3 <obj-list)'
100 +
101 +rm -fr .git2
102 +mkdir .git2
103 +
104 +test_expect_success \
105 + 'unpack with OFS_DELTA' \
106 + 'GIT_OBJECT_DIRECTORY=.git2/objects &&
107 + export GIT_OBJECT_DIRECTORY &&
108 + git-init &&
109 + git-unpack-objects -n <test-3-${packname_3}.pack &&
110 + git-unpack-objects <test-3-${packname_3}.pack'
111 +
112 +unset GIT_OBJECT_DIRECTORY
113 +cd "$TRASH/.git2"
114 +test_expect_success \
115 + 'check unpack with OFS_DELTA' \
116 + '(cd ../.git && find objects -type f -print) |
117 + while read path
118 + do
119 + cmp $path ../.git/$path || {
120 + echo $path differs.
121 + return 1
122 + }
123 + done'
124 +cd "$TRASH"
125 +
126 +test_expect_success \
127 + 'compare delta flavors' \
128 + 'size_2=`stat -c "%s" test-2-${packname_2}.pack` &&
129 + size_3=`stat -c "%s" test-3-${packname_3}.pack` &&
130 + test $size_2 -gt $size_3'
131 +
132 rm -fr .git2
133 mkdir .git2
134
@@ -111,9 +147,8 @@ test_expect_success \
147 } >current &&
148 diff expect current'
149
114 -
150 test_expect_success \
116 - 'use packed deltified objects' \
151 + 'use packed deltified (REF_DELTA) objects' \
152 'GIT_OBJECT_DIRECTORY=.git2/objects &&
153 export GIT_OBJECT_DIRECTORY &&
154 rm .git2/objects/pack/test-* &&
@@ -127,11 +162,28 @@ test_expect_success \
162 } >current &&
163 diff expect current'
164
165 +test_expect_success \
166 + 'use packed deltified (OFS_DELTA) objects' \
167 + 'GIT_OBJECT_DIRECTORY=.git2/objects &&
168 + export GIT_OBJECT_DIRECTORY &&
169 + rm .git2/objects/pack/test-* &&
170 + cp test-3-${packname_3}.pack test-3-${packname_3}.idx .git2/objects/pack && {
171 + git-diff-tree --root -p $commit &&
172 + while read object
173 + do
174 + t=`git-cat-file -t $object` &&
175 + git-cat-file $t $object || return 1
176 + done <obj-list
177 + } >current &&
178 + diff expect current'
179 +
180 unset GIT_OBJECT_DIRECTORY
181
182 test_expect_success \
183 'verify pack' \
134 - 'git-verify-pack test-1-${packname_1}.idx test-2-${packname_2}.idx'
184 + 'git-verify-pack test-1-${packname_1}.idx \
185 + test-2-${packname_2}.idx \
186 + test-3-${packname_3}.idx'
187
188 test_expect_success \
189 'corrupt a pack and see if verify catches' \
@@ -194,6 +246,13 @@ test_expect_success \
246 git-index-pack test-3.pack &&
247 cmp test-3.idx test-2-${packname_2}.idx &&
248
249 + cp test-3-${packname_3}.pack test-3.pack &&
250 + git-index-pack -o tmp.idx test-3-${packname_3}.pack &&
251 + cmp tmp.idx test-3-${packname_3}.idx &&
252 +
253 + git-index-pack test-3.pack &&
254 + cmp test-3.idx test-3-${packname_3}.idx &&
255 +
256 :'
257
258 test_done