t5300: add test for 'show-index --object-format'
In 88a09a557c (builtin/show-index: provide options to determine hash algo), the flag --object-format was added to show-index builtin as a way to provide a hash algorithm explicitly. However, we do not have tests in place for that functionality. Add them. Signed-off-by: Abhijeet Sonar <abhijeet.nkt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Abhijeet Sonar committed
Nov 9, 2024 at 14:57 UTC
34d3f2a984eed5c31384e384f391293d38478036
1 file changed
+14
t/t5300-pack-object.sh
+14
@@ -527,6 +527,20 @@ test_expect_success SHA1 'show-index works OK outside a repository' '
527
nongit git show-index <foo.idx
528
'
529
530
+for hash in sha1 sha256
531
+do
532
+ test_expect_success 'show-index works OK outside a repository with hash algo passed in via --object-format' '
533
+ test_when_finished "rm -rf explicit-hash-$hash" &&
534
+ git init --object-format=$hash explicit-hash-$hash &&
535
+ test_commit -C explicit-hash-$hash one &&
536
+ git -C explicit-hash-$hash rev-parse one >in &&
537
+ git -C explicit-hash-$hash pack-objects explicit-hash-$hash <in &&
538
+ idx=$(echo explicit-hash-$hash/explicit-hash-$hash*.idx) &&
539
+ nongit git show-index --object-format=$hash <"$idx" >actual &&
540
+ test_line_count = 1 actual
541
+ '
542
+done
543
+
544
test_expect_success !PTHREADS,!FAIL_PREREQS \
545
'index-pack --threads=N or pack.threads=N warns when no pthreads' '
546
test_must_fail git index-pack --threads=2 2>err &&