3 test_description
='Test reffiles backend consistency check'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 GIT_TEST_DEFAULT_REF_FORMAT
=files
8 export GIT_TEST_DEFAULT_REF_FORMAT
9 TEST_PASSES_SANITIZE_LEAK
=true
13 test_expect_success
'ref name should be checked' '
14 test_when_finished "rm -rf repo" &&
16 branch_dir_prefix=.git/refs/heads &&
17 tag_dir_prefix=.git/refs/tags &&
20 git commit --allow-empty -m initial &&
21 git checkout -b branch-1 &&
23 git commit --allow-empty -m second &&
24 git checkout -b branch-2 &&
26 git tag multi_hierarchy/tag-2 &&
28 cp $branch_dir_prefix/branch-1 $branch_dir_prefix/.branch-1 &&
29 test_must_fail git refs verify 2>err &&
31 error: refs/heads/.branch-1: badRefName: invalid refname format
33 rm $branch_dir_prefix/.branch-1 &&
34 test_cmp expect err &&
36 cp $branch_dir_prefix/branch-1 $branch_dir_prefix/@ &&
37 test_must_fail git refs verify 2>err &&
39 error: refs/heads/@: badRefName: invalid refname format
41 rm $branch_dir_prefix/@ &&
42 test_cmp expect err &&
44 cp $tag_dir_prefix/multi_hierarchy/tag-2 $tag_dir_prefix/multi_hierarchy/@ &&
45 test_must_fail git refs verify 2>err &&
47 error: refs/tags/multi_hierarchy/@: badRefName: invalid refname format
49 rm $tag_dir_prefix/multi_hierarchy/@ &&
50 test_cmp expect err &&
52 cp $tag_dir_prefix/tag-1 $tag_dir_prefix/tag-1.lock &&
53 git refs verify 2>err &&
54 rm $tag_dir_prefix/tag-1.lock &&
55 test_must_be_empty err &&
57 cp $tag_dir_prefix/tag-1 $tag_dir_prefix/.lock &&
58 test_must_fail git refs verify 2>err &&
60 error: refs/tags/.lock: badRefName: invalid refname format
62 rm $tag_dir_prefix/.lock &&
66 test_expect_success
'ref name check should be adapted into fsck messages' '
67 test_when_finished "rm -rf repo" &&
69 branch_dir_prefix=.git/refs/heads &&
70 tag_dir_prefix=.git/refs/tags &&
72 git commit --allow-empty -m initial &&
73 git checkout -b branch-1 &&
75 git commit --allow-empty -m second &&
76 git checkout -b branch-2 &&
79 cp $branch_dir_prefix/branch-1 $branch_dir_prefix/.branch-1 &&
80 git -c fsck.badRefName=warn refs verify 2>err &&
82 warning: refs/heads/.branch-1: badRefName: invalid refname format
84 rm $branch_dir_prefix/.branch-1 &&
85 test_cmp expect err &&
87 cp $branch_dir_prefix/branch-1 $branch_dir_prefix/@ &&
88 git -c fsck.badRefName=ignore refs verify 2>err &&
89 test_must_be_empty err