pack-objects: extend test coverage of `--stdin-packs` with alternates

We don't have any tests that verify that git-pack-objects(1) works with `--stdin-packs` when combined with alternate object directories. Add some to make sure that the basic functionality works as expected. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Apr 14, 2023 at 08:01 UTC f3028418c3b68350aa810064c95283062c9157d6
1 file changed +48
t/t5331-pack-objects-stdin.sh
+48
@@ -189,4 +189,52 @@ test_expect_success 'pack-objects --stdin with same packfile excluded and includ
189 )
190 '
191
192 +test_expect_success 'pack-objects --stdin with packfiles from alternate object database' '
193 + test_when_finished "rm -fr shared member" &&
194 +
195 + # Set up a shared repository with a single packfile.
196 + git init shared &&
197 + test_commit -C shared "shared-objects" &&
198 + git -C shared repack -ad &&
199 + basename shared/.git/objects/pack/pack-*.pack >packfile &&
200 +
201 + # Set up a repository that is connected to the shared repository. This
202 + # repository has no objects on its own, but we still expect to be able
203 + # to pack objects from its alternate.
204 + git clone --shared shared member &&
205 + git -C member pack-objects --stdin-packs generated-pack <packfile &&
206 + test_cmp shared/.git/objects/pack/pack-*.pack member/generated-pack-*.pack
207 +'
208 +
209 +test_expect_success 'pack-objects --stdin with packfiles from main and alternate object database' '
210 + test_when_finished "rm -fr shared member" &&
211 +
212 + # Set up a shared repository with a single packfile.
213 + git init shared &&
214 + test_commit -C shared "shared-commit" &&
215 + git -C shared repack -ad &&
216 +
217 + # Set up a repository that is connected to the shared repository. This
218 + # repository has a second packfile so that we can verify that it is
219 + # possible to write packs that include packfiles from different object
220 + # databases.
221 + git clone --shared shared member &&
222 + test_commit -C member "local-commit" &&
223 + git -C member repack -dl &&
224 +
225 + {
226 + basename shared/.git/objects/pack/pack-*.pack &&
227 + basename member/.git/objects/pack/pack-*.pack
228 + } >packfiles &&
229 +
230 + {
231 + packed_objects shared/.git/objects/pack/pack-*.idx &&
232 + packed_objects member/.git/objects/pack/pack-*.idx
233 + } | sort >expected-objects &&
234 +
235 + git -C member pack-objects --stdin-packs generated-pack <packfiles &&
236 + packed_objects member/generated-pack-*.idx >actual-objects &&
237 + test_cmp expected-objects actual-objects
238 +'
239 +
240 test_done