]> git.ipfire.org Git - thirdparty/git.git/commit
ref: check the full refname instead of basename
authorshejialuo <shejialuo@gmail.com>
Wed, 20 Nov 2024 11:51:16 +0000 (19:51 +0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Nov 2024 23:21:31 +0000 (08:21 +0900)
commit32dc1c7ec3c4e92704f221abbfee5cc1d50bf473
treeed4350666679626cb952a1da1d3538efe19979a9
parent38cd6eead19f3d7359ebd34cae6f2a37de4ccc10
ref: check the full refname instead of basename

In "files-backend.c::files_fsck_refs_name", we validate the refname
format by using "check_refname_format" to check the basename of the
iterator with "REFNAME_ALLOW_ONELEVEL" flag.

However, this is a bad implementation. Although we doesn't allow a
single "@" in ".git" directory, we do allow "refs/heads/@". So, we will
report an error wrongly when there is a "refs/heads/@" ref by using one
level refname "@".

Because we just check one level refname, we either cannot check the
other parts of the full refname. And we will ignore the following
errors:

  "refs/heads/ new-feature/test"
  "refs/heads/~new-feature/test"

In order to fix the above problem, enhance "files_fsck_refs_name" to use
the full name for "check_refname_format". Then, replace the tests which
are related to "@" and add tests to exercise the above situations using
for loop to avoid repetition.

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>
refs/files-backend.c
t/t0602-reffiles-fsck.sh