Skip to content

Commit 34d3f2a

Browse files
quanta-ktgitster
authored andcommitted
t5300: add test for 'show-index --object-format'
In 88a09a5 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4da8d90 commit 34d3f2a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

t/t5300-pack-object.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,20 @@ test_expect_success SHA1 'show-index works OK outside a repository' '
527527
nongit git show-index <foo.idx
528528
'
529529

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+
530544
test_expect_success !PTHREADS,!FAIL_PREREQS \
531545
'index-pack --threads=N or pack.threads=N warns when no pthreads' '
532546
test_must_fail git index-pack --threads=2 2>err &&

0 commit comments

Comments
 (0)