Skip to content

Commit 05d2091

Browse files
pks-tgitster
authored andcommitted
t0001: exercise initialization with ref formats more thoroughly
While our object format tests for git-init(1) exercise tests with all known formats in t0001, the tests for the ref format don't. This leads to some missing test coverage for interesting cases, like whether or not a non-default ref storage format causes us to bump the repository format version. We also don't test for the precedence of the `--ref-format=` and the `GIT_DEFAULT_REF_FORMAT=` environment variable. Extend the test suite to cover more scenarios related to the ref format. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 477ce5c commit 05d2091

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

t/t0001-init.sh

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,6 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.refStorage with unknown back
558558
grep "invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}garbage${SQ}" err
559559
'
560560

561-
test_expect_success DEFAULT_REPO_FORMAT 'init with GIT_DEFAULT_REF_FORMAT=files' '
562-
test_when_finished "rm -rf refformat" &&
563-
GIT_DEFAULT_REF_FORMAT=files git init refformat &&
564-
echo 0 >expect &&
565-
git -C refformat config core.repositoryformatversion >actual &&
566-
test_cmp expect actual &&
567-
test_must_fail git -C refformat config extensions.refstorage
568-
'
569-
570561
test_expect_success 'init with GIT_DEFAULT_REF_FORMAT=garbage' '
571562
test_when_finished "rm -rf refformat" &&
572563
cat >expect <<-EOF &&
@@ -576,15 +567,46 @@ test_expect_success 'init with GIT_DEFAULT_REF_FORMAT=garbage' '
576567
test_cmp expect err
577568
'
578569

579-
test_expect_success 'init with --ref-format=files' '
570+
backends="files reftable"
571+
for format in $backends
572+
do
573+
test_expect_success DEFAULT_REPO_FORMAT "init with GIT_DEFAULT_REF_FORMAT=$format" '
574+
test_when_finished "rm -rf refformat" &&
575+
GIT_DEFAULT_REF_FORMAT=$format git init refformat &&
576+
577+
if test $format = files
578+
then
579+
test_must_fail git -C refformat config extensions.refstorage &&
580+
echo 0 >expect
581+
else
582+
git -C refformat config extensions.refstorage &&
583+
echo 1 >expect
584+
fi &&
585+
git -C refformat config core.repositoryformatversion >actual &&
586+
test_cmp expect actual &&
587+
588+
echo $format >expect &&
589+
git -C refformat rev-parse --show-ref-format >actual &&
590+
test_cmp expect actual
591+
'
592+
593+
test_expect_success "init with --ref-format=$format" '
594+
test_when_finished "rm -rf refformat" &&
595+
git init --ref-format=$format refformat &&
596+
echo $format >expect &&
597+
git -C refformat rev-parse --show-ref-format >actual &&
598+
test_cmp expect actual
599+
'
600+
done
601+
602+
test_expect_success "--ref-format= overrides GIT_DEFAULT_REF_FORMAT" '
580603
test_when_finished "rm -rf refformat" &&
581-
git init --ref-format=files refformat &&
582-
echo files >expect &&
604+
GIT_DEFAULT_REF_FORMAT=files git init --ref-format=reftable refformat &&
605+
echo reftable >expect &&
583606
git -C refformat rev-parse --show-ref-format >actual &&
584607
test_cmp expect actual
585608
'
586609

587-
backends="files reftable"
588610
for from_format in $backends
589611
do
590612
test_expect_success "re-init with same format ($from_format)" '

0 commit comments

Comments
 (0)