]> git.ipfire.org Git - thirdparty/git.git/commit
fsck: add ref name check for files backend
authorshejialuo <shejialuo@gmail.com>
Thu, 8 Aug 2024 11:31:42 +0000 (19:31 +0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Aug 2024 16:36:53 +0000 (09:36 -0700)
commit1c31be45b3b263670c7d2a91c27cc119b77dd2e2
treed843a268b7200c0def39a6d36c139a7d26b64ed8
parenta7600b8481b533d77a2cc5f03acdbed12b996fcd
fsck: add ref name check for files backend

The git-fsck(1) only implicitly checks the reference, it does not fully
check refs with bad format name such as standalone "@".

However, a file ending with ".lock" should not be marked as having a bad
ref name. It is expected that concurrent writers may have such lock files.
We currently ignore this situation. But for bare ".lock" file, we will
report it as error.

In order to provide such checks, add a new fsck message id "badRefName"
with default ERROR type. Use existing "check_refname_format" to explicit
check the ref name. And add a new unit test to verify the functionality.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/fsck-msgids.txt
fsck.h
refs/files-backend.c
t/t0602-reffiles-fsck.sh [new file with mode: 0755]