226
return opts && oid && oidset_contains(&opts->skip_oids, oid);
227
}
228
229
-__attribute__((format (printf, 5, 6)))
230
-static int report(struct fsck_options *options,
231
- const struct object_id *oid, enum object_type object_type,
232
- enum fsck_msg_id msg_id, const char *fmt, ...)
229
+/*
230
+ * Provide the common functionality for either fscking refs or objects.
231
+ * It will get the current msg error type and call the error_func callback
232
+ * which is registered in the "fsck_options" struct.
233
+ */
234
+static int fsck_vreport(struct fsck_options *options,
235
+ void *fsck_report,
236
+ enum fsck_msg_id msg_id, const char *fmt, va_list ap)
237
{
234
- va_list ap;
235
- struct fsck_object_report report = {
236
- .oid = oid,
237
- .object_type = object_type
238
- };
238
struct strbuf sb = STRBUF_INIT;
239
enum fsck_msg_type msg_type = fsck_msg_type(msg_id, options);
240
int result;
242
if (msg_type == FSCK_IGNORE)
243
return 0;
244
246
- if (object_on_skiplist(options, oid))
247
- return 0;
248
-
245
if (msg_type == FSCK_FATAL)
246
msg_type = FSCK_ERROR;
247
else if (msg_type == FSCK_INFO)
250
prepare_msg_ids();
251
strbuf_addf(&sb, "%s: ", msg_id_info[msg_id].camelcased);
252
257
- va_start(ap, fmt);
253
strbuf_vaddf(&sb, fmt, ap);
259
- result = options->error_func(options, &report,
254
+ result = options->error_func(options, fsck_report,
255
msg_type, msg_id, sb.buf);
256
strbuf_release(&sb);
257
+
258
+ return result;
259
+}
260
+
261
+__attribute__((format (printf, 5, 6)))
262
+static int report(struct fsck_options *options,
263
+ const struct object_id *oid, enum object_type object_type,
264
+ enum fsck_msg_id msg_id, const char *fmt, ...)
265
+{
266
+ va_list ap;
267
+ struct fsck_object_report report = {
268
+ .oid = oid,
269
+ .object_type = object_type
270
+ };
271
+ int result;
272
+
273
+ if (object_on_skiplist(options, oid))
274
+ return 0;
275
+
276
+ va_start(ap, fmt);
277
+ result = fsck_vreport(options, &report, msg_id, fmt, ap);
278
va_end(ap);
279
280
return result;