ref: port git-fsck(1) regular refs check for files backend
"git-fsck(1)" implicitly checks the ref content by passing the
callback "fsck_handle_ref" to the "refs.c::refs_for_each_rawref".
Then, it will check whether the ref content (eventually "oid")
is valid. If not, it will report the following error to the user.
error: refs/heads/main: invalid sha1 pointer 0000...
And it will also report above errors when there are dangling symrefs
in the repository wrongly. This does not align with the behavior of
the "git symbolic-ref" command which allows users to create dangling
symrefs.
As we have already introduced the "git refs verify" command, we'd better
check the ref content explicitly in the "git refs verify" command thus
later we could remove these checks in "git-fsck(1)" and launch a
subprocess to call "git refs verify" in "git-fsck(1)" to make the
"git-fsck(1)" more clean.
Following what "git-fsck(1)" does, add a similar check to "git refs
verify". Then add a new fsck error message "badRefContent(ERROR)" to
represent that a ref has an invalid content.
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>
shejialuo committedNov 20, 2024 at 19:51 UTC824aa541aae7a35f32f9dabc54f8a97861488013
4 files changed+156
Documentation/fsck-msgids.txt
+3
index 68a2801f15..22c385ea22 100644--- a/Documentation/fsck-msgids.txt+++ b/Documentation/fsck-msgids.txt@@ -19,6 +19,9 @@ `badParentSha1`:: (ERROR) A commit object has a bad parent sha1.+`badRefContent`::+ (ERROR) A ref has bad content.+ `badRefFiletype`:: (ERROR) A ref has a bad file type.