Skip to content

Commit 8ba221e

Browse files
derrickstoleegitster
authored andcommitted
bundle: output hash information in 'verify'
The previous change moved the 'filter' capability to the end of the 'git bundle verify' output. Now, add the 'object-format' capability to the output, when it exists. This change makes 'git bundle verify' output the hash used in all cases, even if the capability is not in the bundle. This means that v2 bundles will always output that they use "sha1". This might look noisy to some users, but it does simplify the implementation and the test strategy for this feature. Since 'verify' ends early when a prerequisite commit is missing, we need to insert this hash message carefully into our expected test output throughout t6020. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 017303e commit 8ba221e

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

bundle.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ int verify_bundle(struct repository *r,
278278
list_refs(r, 0, NULL);
279279
}
280280

281+
printf_ln("The bundle uses this hash algorithm: %s",
282+
header->hash_algo->name);
281283
if (header->filter.choice)
282284
printf_ln("The bundle uses this filter: %s",
283285
list_objects_filter_spec(&header->filter));

t/t6020-bundle-misc.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ format_and_save_expect () {
122122
sed -e 's/Z$//' >expect
123123
}
124124

125+
HASH_MESSAGE="The bundle uses this hash algorithm: $GIT_DEFAULT_HASH"
126+
125127
# (C) (D, pull/1/head, topic/1)
126128
# o --- o
127129
# / \ (L)
@@ -194,11 +196,12 @@ test_expect_success 'create bundle from special rev: main^!' '
194196
195197
git bundle verify special-rev.bdl |
196198
make_user_friendly_and_stable_output >actual &&
197-
format_and_save_expect <<-\EOF &&
199+
format_and_save_expect <<-EOF &&
198200
The bundle contains this ref:
199201
<COMMIT-P> refs/heads/main
200202
The bundle requires this ref:
201203
<COMMIT-O> Z
204+
$HASH_MESSAGE
202205
EOF
203206
test_cmp expect actual &&
204207
@@ -215,12 +218,13 @@ test_expect_success 'create bundle with --max-count option' '
215218
216219
git bundle verify max-count.bdl |
217220
make_user_friendly_and_stable_output >actual &&
218-
format_and_save_expect <<-\EOF &&
221+
format_and_save_expect <<-EOF &&
219222
The bundle contains these 2 refs:
220223
<COMMIT-P> refs/heads/main
221224
<TAG-1> refs/tags/v1
222225
The bundle requires this ref:
223226
<COMMIT-O> Z
227+
$HASH_MESSAGE
224228
EOF
225229
test_cmp expect actual &&
226230
@@ -240,7 +244,7 @@ test_expect_success 'create bundle with --since option' '
240244
241245
git bundle verify since.bdl |
242246
make_user_friendly_and_stable_output >actual &&
243-
format_and_save_expect <<-\EOF &&
247+
format_and_save_expect <<-EOF &&
244248
The bundle contains these 5 refs:
245249
<COMMIT-P> refs/heads/main
246250
<COMMIT-N> refs/heads/release
@@ -250,6 +254,7 @@ test_expect_success 'create bundle with --since option' '
250254
The bundle requires these 2 refs:
251255
<COMMIT-M> Z
252256
<COMMIT-K> Z
257+
$HASH_MESSAGE
253258
EOF
254259
test_cmp expect actual &&
255260
@@ -267,11 +272,12 @@ test_expect_success 'create bundle 1 - no prerequisites' '
267272
EOF
268273
git bundle create stdin-1.bdl --stdin <input &&
269274
270-
cat >expect <<-\EOF &&
275+
format_and_save_expect <<-EOF &&
271276
The bundle contains these 2 refs:
272277
<COMMIT-D> refs/heads/topic/1
273278
<COMMIT-H> refs/heads/topic/2
274279
The bundle records a complete history.
280+
$HASH_MESSAGE
275281
EOF
276282
277283
# verify bundle, which has no prerequisites
@@ -308,13 +314,14 @@ test_expect_success 'create bundle 2 - has prerequisites' '
308314
--stdin \
309315
release <input &&
310316
311-
format_and_save_expect <<-\EOF &&
317+
format_and_save_expect <<-EOF &&
312318
The bundle contains this ref:
313319
<COMMIT-N> refs/heads/release
314320
The bundle requires these 3 refs:
315321
<COMMIT-D> Z
316322
<COMMIT-E> Z
317323
<COMMIT-G> Z
324+
$HASH_MESSAGE
318325
EOF
319326
320327
git bundle verify 2.bdl |
@@ -367,13 +374,14 @@ test_expect_success 'create bundle 3 - two refs, same object' '
367374
--stdin \
368375
main HEAD <input &&
369376
370-
format_and_save_expect <<-\EOF &&
377+
format_and_save_expect <<-EOF &&
371378
The bundle contains these 2 refs:
372379
<COMMIT-P> refs/heads/main
373380
<COMMIT-P> HEAD
374381
The bundle requires these 2 refs:
375382
<COMMIT-M> Z
376383
<COMMIT-K> Z
384+
$HASH_MESSAGE
377385
EOF
378386
379387
git bundle verify 3.bdl |
@@ -409,12 +417,13 @@ test_expect_success 'create bundle 4 - with tags' '
409417
--stdin \
410418
--all <input &&
411419
412-
cat >expect <<-\EOF &&
420+
cat >expect <<-EOF &&
413421
The bundle contains these 3 refs:
414422
<TAG-1> refs/tags/v1
415423
<TAG-2> refs/tags/v2
416424
<TAG-3> refs/tags/v3
417425
The bundle records a complete history.
426+
$HASH_MESSAGE
418427
EOF
419428
420429
git bundle verify 4.bdl |
@@ -511,6 +520,7 @@ do
511520
<TAG-3> refs/tags/v3
512521
<COMMIT-P> HEAD
513522
The bundle records a complete history.
523+
$HASH_MESSAGE
514524
The bundle uses this filter: $filter
515525
EOF
516526
test_cmp expect actual &&

0 commit comments

Comments
 (0)