refs/files: introduce function to perform normal ref checks

In a subsequent commit we'll introduce new generic checks for direct
refs. These checks will be independent of the actual backend.

Introduce a new function `refs_fsck_ref()` that will be used for this
purpose. At the current point in time it's still empty, but it will get
populated in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt 2026-01-09 13:39:39 +01:00 committed by Junio C Hamano
parent 0213630269
commit 0a83639888
3 changed files with 17 additions and 0 deletions

7
refs.c
View File

@ -320,6 +320,13 @@ int check_refname_format(const char *refname, int flags)
return check_or_sanitize_refname(refname, flags, NULL);
}
int refs_fsck_ref(struct ref_store *refs UNUSED, struct fsck_options *o UNUSED,
struct fsck_ref_report *report UNUSED,
const char *refname UNUSED, const struct object_id *oid UNUSED)
{
return 0;
}
int refs_fsck_symref(struct ref_store *refs UNUSED, struct fsck_options *o,
struct fsck_ref_report *report,
const char *refname UNUSED, const char *target)

8
refs.h
View File

@ -655,6 +655,14 @@ int check_refname_format(const char *refname, int flags);
struct fsck_ref_report;
/*
* Perform generic checks for a specific symref target. This function is
* expected to be called by the ref backends for every symbolic ref.
*/
int refs_fsck_ref(struct ref_store *refs, struct fsck_options *o,
struct fsck_ref_report *report,
const char *refname, const struct object_id *oid);
/*
* Perform generic checks for a specific symref target. This function is
* expected to be called by the ref backends for every symbolic ref.

View File

@ -3833,6 +3833,8 @@ static int files_fsck_refs_content(struct ref_store *ref_store,
"has trailing garbage: '%s'", trailing);
goto cleanup;
}
ret = refs_fsck_ref(ref_store, o, &report, target_name, &oid);
} else {
ret = files_fsck_symref_target(ref_store, o, &report,
target_name, &referent, 0);