summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-05-27 14:15:44 +0900
committerJunio C Hamano <gitster@pobox.com>2026-05-27 14:15:44 +0900
commitbbcc0ae3e94be45320ca7bbd31dbc2a2ce58ea8d (patch)
tree94049044553dd896a3f5057e723155d9fdd9fdc6 /t
parentc5e6e497ac6c9a80ec4b04752cce1c35337bd6b9 (diff)
parente0fcba2d9cf86ba45943066924f111006d55ba08 (diff)
Merge branch 'kn/refs-fsck-skip-lock-files'
The consistency checks for the files reference backend have been updated to skip lock files earlier, avoiding unnecessary parsing of intermediate files. * kn/refs-fsck-skip-lock-files: refs/files: skip lock files during consistency checks
Diffstat (limited to 't')
-rwxr-xr-xt/t0602-reffiles-fsck.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/t0602-reffiles-fsck.sh b/t/t0602-reffiles-fsck.sh
index 3c1f553b81..13259821a0 100755
--- a/t/t0602-reffiles-fsck.sh
+++ b/t/t0602-reffiles-fsck.sh
@@ -87,6 +87,47 @@ test_expect_success 'ref name should be checked' '
)
'
+test_expect_success 'lock files should be ignored' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ git commit --allow-empty -m initial &&
+ git checkout -b branch-1 &&
+
+ touch .git/refs/heads/branch-1.lock &&
+ git refs verify 2>err &&
+ test_must_be_empty err &&
+
+ echo "foobar" >.git/refs/heads/branch-2 &&
+ test_must_fail git refs verify 2>err &&
+ cat >expect <<-EOF &&
+ error: refs/heads/branch-2: badRefContent: foobar
+ EOF
+ test_cmp expect err
+ )
+'
+
+test_expect_success 'bare lock files should not be ignored' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ git commit --allow-empty -m initial &&
+ git checkout -b branch-1 &&
+
+ # invalid refname should be reported
+ cp .git/refs/heads/branch-1 .git/refs/heads/.branch-1.lock &&
+ # invalid refname and content should be reported
+ touch .git/refs/heads/.lock &&
+
+ test_must_fail git refs verify 2>err &&
+ test_grep "error: refs/heads/.branch-1.lock: badRefName: invalid refname format" err &&
+ test_grep "error: refs/heads/.lock: badRefName: invalid refname format" err &&
+ test_grep "error: refs/heads/.lock: badRefContent: " err
+ )
+'
+
test_expect_success 'ref name check should be adapted into fsck messages' '
test_when_finished "rm -rf repo" &&
git init repo &&