fsck.h: move FSCK_{FATAL,INFO,ERROR,WARN,IGNORE} into an enum

Move the FSCK_{FATAL,INFO,ERROR,WARN,IGNORE} defines into a new
fsck_msg_type enum.

These defines were originally introduced in:

 - ba002f3b28 (builtin-fsck: move common object checking code to
   fsck.c, 2008-02-25)
 - f50c440730 (fsck: disallow demoting grave fsck errors to warnings,
   2015-06-22)
 - efaba7cc77 (fsck: optionally ignore specific fsck issues
   completely, 2015-06-22)
 - f27d05b170 (fsck: allow upgrading fsck warnings to errors,
   2015-06-22)

The reason these were defined in two different places is because we
use FSCK_{IGNORE,INFO,FATAL} only in fsck.c, but FSCK_{ERROR,WARN} are
used by external callbacks.

Untangling that would take some more work, since we expose the new
"enum fsck_msg_type" to both. Similar to "enum object_type" it's not
worth structuring the API in such a way that only those who need
FSCK_{ERROR,WARN} pass around a different type.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2021-03-28 15:15:40 +02:00
committed by Junio C Hamano
parent e35d65a78a
commit 1b32b59f9b
5 changed files with 25 additions and 20 deletions

16
fsck.h
View File

@ -3,9 +3,13 @@
#include "oidset.h"
#define FSCK_ERROR 1
#define FSCK_WARN 2
#define FSCK_IGNORE 3
enum fsck_msg_type {
FSCK_INFO = -2,
FSCK_FATAL = -1,
FSCK_ERROR = 1,
FSCK_WARN,
FSCK_IGNORE
};
struct fsck_options;
struct object;
@ -29,17 +33,17 @@ typedef int (*fsck_walk_func)(struct object *obj, enum object_type object_type,
/* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */
typedef int (*fsck_error)(struct fsck_options *o,
const struct object_id *oid, enum object_type object_type,
int msg_type, const char *message);
enum fsck_msg_type msg_type, const char *message);
int fsck_error_function(struct fsck_options *o,
const struct object_id *oid, enum object_type object_type,
int msg_type, const char *message);
enum fsck_msg_type msg_type, const char *message);
struct fsck_options {
fsck_walk_func walk;
fsck_error error_func;
unsigned strict:1;
int *msg_type;
enum fsck_msg_type *msg_type;
struct oidset skiplist;
kh_oid_map_t *object_names;
};