]> git.ipfire.org Git - thirdparty/git.git/commit
refs/files: skip lock files during consistency checks
authorKarthik Nayak <karthik.188@gmail.com>
Sun, 17 May 2026 17:32:05 +0000 (19:32 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 17 May 2026 23:43:32 +0000 (08:43 +0900)
commite0fcba2d9cf86ba45943066924f111006d55ba08
tree7e37e68c1b56cbd2acb8658765898ac6f45b867d
parent94f057755b7941b321fd11fec1b2e3ca5313a4e0
refs/files: skip lock files during consistency checks

Consistency checks in the files reference backend involve two steps:

1. Iterate over all entries within the 'refs/' directory and call
`files_fsck_ref()` on each.
2. Iterate over all root refs via `for_each_root_ref()` and call
`files_fsck_ref()` on each.

`files_fsck_ref()` then runs all fsck checks defined in
`fsck_refs_fn[]`. Step 2 goes through the refs API and only sees valid
refs, but step 1 iterates the directory directly and may also encounter
intermediate '*.lock' files.

Currently, `files_fsck_refs_name()`, one of the functions in
`fsck_refs_fn[]`, filters out lock files itself. The other function,
`files_fsck_refs_content()`, has no such check and would parse the lock
file. Any new function added to `fsck_refs_fn[]` would have the same
problem.

Move the filter up into `files_fsck_refs_dir()`, where the directory
iteration happens. Since step 2 cannot produce lock files, this is the
only site where the filter is needed, and individual checks no longer
have to re-implement it.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c
t/t0602-reffiles-fsck.sh