]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs/files: introduce function to perform normal ref checks
authorPatrick Steinhardt <ps@pks.im>
Mon, 12 Jan 2026 09:02:59 +0000 (10:02 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Jan 2026 14:55:41 +0000 (06:55 -0800)
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>
refs.c
refs.h
refs/files-backend.c

diff --git a/refs.c b/refs.c
index 739bf9fefc7bbfc7ebb72ec727d09a3e1222d868..4fc1317cb32323893828108a342141f7985ba081 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -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)
diff --git a/refs.h b/refs.h
index d91fcb2d2f05263d304fbdddf6cc89cb16f92210..f0abfa1d93633e1bc2cb0aa2e1789935c6431aa5 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -655,6 +655,14 @@ int check_refname_format(const char *refname, int flags);
 
 struct fsck_ref_report;
 
+/*
+ * Perform generic checks for a specific direct ref. 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.
index 687c26ddcbc8c767dff64aa2c6da099772d68345..240d3c3b26e0b551d1fe61d102fbfd534173802e 100644 (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);