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>
Derrick Stolee committed
Mar 22, 2022 at 17:28 UTC
8ba221e2453658f8843176cc00fc5cfe36e07b41
2 files changed
+19
-7
bundle.c
+2
@@ -278,6 +278,8 @@ int verify_bundle(struct repository *r,
278
list_refs(r, 0, NULL);
279
}
280
281
+ printf_ln("The bundle uses this hash algorithm: %s",
282
+ header->hash_algo->name);
283
if (header->filter.choice)
284
printf_ln("The bundle uses this filter: %s",
285
list_objects_filter_spec(&header->filter));
t/t6020-bundle-misc.sh
+17
-7
@@ -122,6 +122,8 @@ format_and_save_expect () {
122
sed -e 's/Z$//' >expect
123
}
124
125
+HASH_MESSAGE="The bundle uses this hash algorithm: $GIT_DEFAULT_HASH"
126
+
127
# (C) (D, pull/1/head, topic/1)
128
# o --- o
129
# / \ (L)
@@ -194,11 +196,12 @@ test_expect_success 'create bundle from special rev: main^!' '
196
197
git bundle verify special-rev.bdl |
198
make_user_friendly_and_stable_output >actual &&
197
- format_and_save_expect <<-\EOF &&
199
+ format_and_save_expect <<-EOF &&
200
The bundle contains this ref:
201
<COMMIT-P> refs/heads/main
202
The bundle requires this ref:
203
<COMMIT-O> Z
204
+ $HASH_MESSAGE
205
EOF
206
test_cmp expect actual &&
207
@@ -215,12 +218,13 @@ test_expect_success 'create bundle with --max-count option' '
218
219
git bundle verify max-count.bdl |
220
make_user_friendly_and_stable_output >actual &&
218
- format_and_save_expect <<-\EOF &&
221
+ format_and_save_expect <<-EOF &&
222
The bundle contains these 2 refs:
223
<COMMIT-P> refs/heads/main
224
<TAG-1> refs/tags/v1
225
The bundle requires this ref:
226
<COMMIT-O> Z
227
+ $HASH_MESSAGE
228
EOF
229
test_cmp expect actual &&
230
@@ -240,7 +244,7 @@ test_expect_success 'create bundle with --since option' '
244
245
git bundle verify since.bdl |
246
make_user_friendly_and_stable_output >actual &&
243
- format_and_save_expect <<-\EOF &&
247
+ format_and_save_expect <<-EOF &&
248
The bundle contains these 5 refs:
249
<COMMIT-P> refs/heads/main
250
<COMMIT-N> refs/heads/release
@@ -250,6 +254,7 @@ test_expect_success 'create bundle with --since option' '
254
The bundle requires these 2 refs:
255
<COMMIT-M> Z
256
<COMMIT-K> Z
257
+ $HASH_MESSAGE
258
EOF
259
test_cmp expect actual &&
260
@@ -267,11 +272,12 @@ test_expect_success 'create bundle 1 - no prerequisites' '
272
EOF
273
git bundle create stdin-1.bdl --stdin <input &&
274
270
- cat >expect <<-\EOF &&
275
+ format_and_save_expect <<-EOF &&
276
The bundle contains these 2 refs:
277
<COMMIT-D> refs/heads/topic/1
278
<COMMIT-H> refs/heads/topic/2
279
The bundle records a complete history.
280
+ $HASH_MESSAGE
281
EOF
282
283
# verify bundle, which has no prerequisites
@@ -308,13 +314,14 @@ test_expect_success 'create bundle 2 - has prerequisites' '
314
--stdin \
315
release <input &&
316
311
- format_and_save_expect <<-\EOF &&
317
+ format_and_save_expect <<-EOF &&
318
The bundle contains this ref:
319
<COMMIT-N> refs/heads/release
320
The bundle requires these 3 refs:
321
<COMMIT-D> Z
322
<COMMIT-E> Z
323
<COMMIT-G> Z
324
+ $HASH_MESSAGE
325
EOF
326
327
git bundle verify 2.bdl |
@@ -367,13 +374,14 @@ test_expect_success 'create bundle 3 - two refs, same object' '
374
--stdin \
375
main HEAD <input &&
376
370
- format_and_save_expect <<-\EOF &&
377
+ format_and_save_expect <<-EOF &&
378
The bundle contains these 2 refs:
379
<COMMIT-P> refs/heads/main
380
<COMMIT-P> HEAD
381
The bundle requires these 2 refs:
382
<COMMIT-M> Z
383
<COMMIT-K> Z
384
+ $HASH_MESSAGE
385
EOF
386
387
git bundle verify 3.bdl |
@@ -409,12 +417,13 @@ test_expect_success 'create bundle 4 - with tags' '
417
--stdin \
418
--all <input &&
419
412
- cat >expect <<-\EOF &&
420
+ cat >expect <<-EOF &&
421
The bundle contains these 3 refs:
422
<TAG-1> refs/tags/v1
423
<TAG-2> refs/tags/v2
424
<TAG-3> refs/tags/v3
425
The bundle records a complete history.
426
+ $HASH_MESSAGE
427
EOF
428
429
git bundle verify 4.bdl |
@@ -511,6 +520,7 @@ do
520
<TAG-3> refs/tags/v3
521
<COMMIT-P> HEAD
522
The bundle records a complete history.
523
+ $HASH_MESSAGE
524
The bundle uses this filter: $filter
525
EOF
526
test_cmp expect actual &&