Re: [GSoC][PATCH v15 5/9] fsck: add refs report function
On Tue, Aug 06, 2024 at 12:45:57AM +0800, shejialuo wrote:
Show 12 quoted lines
> @@ -1237,6 +1250,34 @@ int fsck_objects_error_function(struct fsck_options *o,
> return 1;
> }
>
> +int fsck_refs_error_function(struct fsck_options *options UNUSED,
> + void *fsck_report,
> + enum fsck_msg_type msg_type,
> + enum fsck_msg_id msg_id UNUSED,
> + const char *message)
> +{
> + struct fsck_ref_report *report = fsck_report;
> +Nit: there's an unneeded empty newline here.
Show 18 quoted lines
> + struct strbuf sb = STRBUF_INIT;
> + int ret = 0;
> +
> + strbuf_addstr(&sb, report->path);
> +
> + if (report->oid)
> + strbuf_addf(&sb, " -> (%s)", oid_to_hex(report->oid));
> + else if (report->referent)
> + strbuf_addf(&sb, " -> (%s)", report->referent);
> +
> + if (msg_type == FSCK_WARN)
> + warning("%s: %s", sb.buf, message);
> + else
> + ret = error("%s: %s", sb.buf, message);
> +
> + strbuf_release(&sb);
> + return ret;
> +