diff mbox series

[GSoC,v14,04/11] fsck: add refs report function

Message ID ZqumQthEwDjoDs6u@ArchLinux (mailing list archive)
State Superseded
Headers show
Series ref consistency check infra setup | expand

Commit Message

shejialuo Aug. 1, 2024, 3:14 p.m. UTC
Introduce a new struct "fsck_ref_report" to contain the information we
need when reporting refs-related messages.

With the new "fsck_vreport" function, add a new function
"fsck_report_ref" to report refs-related fsck error message. Unlike
"report" function uses the exact parameters, we simply pass "struct
fsck_ref_report *report" as the parameter. This is because at current we
don't know exactly how many fields we need. By passing this parameter,
we don't need to change this function prototype when we want to add more
information into "fsck_ref_report".

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: shejialuo <shejialuo@gmail.com>
---
 fsck.c | 13 +++++++++++++
 fsck.h | 16 ++++++++++++++++
 2 files changed, 29 insertions(+)

Comments

Patrick Steinhardt Aug. 5, 2024, 12:58 p.m. UTC | #1
On Thu, Aug 01, 2024 at 11:14:10PM +0800, shejialuo wrote:
> @@ -216,6 +222,16 @@ int fsck_tag_standalone(const struct object_id *oid, const char *buffer,
>   */
>  int fsck_finish(struct fsck_options *options);
>  
> +/*
> + * Report an error or warning for refs.
> + */
> +__attribute__((format (printf, 4, 5)))
> +int fsck_report_ref(struct fsck_options *options,
> +		    struct fsck_ref_report *report,
> +		    enum fsck_msg_id msg_id,
> +		    const char *fmt, ...);

Nice that we got rid of the parts that don't matter for reporting refs
now.

Patrick
diff mbox series

Patch

diff --git a/fsck.c b/fsck.c
index b394a9e397..ee888c1417 100644
--- a/fsck.c
+++ b/fsck.c
@@ -283,6 +283,19 @@  static int report(struct fsck_options *options,
 	return result;
 }
 
+int fsck_report_ref(struct fsck_options *options,
+		    struct fsck_ref_report *report,
+		    enum fsck_msg_id msg_id,
+		    const char *fmt, ...)
+{
+	va_list ap;
+	int result;
+	va_start(ap, fmt);
+	result = fsck_vreport(options, report, msg_id, fmt, ap);
+	va_end(ap);
+	return result;
+}
+
 void fsck_enable_object_names(struct fsck_options *options)
 {
 	if (!options->object_names)
diff --git a/fsck.h b/fsck.h
index 303174a5d8..0918c28d0f 100644
--- a/fsck.h
+++ b/fsck.h
@@ -138,6 +138,12 @@  struct fsck_object_report {
 	enum object_type object_type;
 };
 
+struct fsck_ref_report {
+	const char *path;
+	const struct object_id *oid;
+	const char *referent;
+};
+
 struct fsck_options {
 	fsck_walk_func walk;
 	fsck_error error_func;
@@ -216,6 +222,16 @@  int fsck_tag_standalone(const struct object_id *oid, const char *buffer,
  */
 int fsck_finish(struct fsck_options *options);
 
+/*
+ * Report an error or warning for refs.
+ */
+__attribute__((format (printf, 4, 5)))
+int fsck_report_ref(struct fsck_options *options,
+		    struct fsck_ref_report *report,
+		    enum fsck_msg_id msg_id,
+		    const char *fmt, ...);
+
+
 /*
  * Subsystem for storing human-readable names for each object.
  *