]>
Commit | Line | Data |
---|---|---|
355885d5 MK |
1 | #ifndef GIT_FSCK_H |
2 | #define GIT_FSCK_H | |
3 | ||
ba002f3b MK |
4 | #define FSCK_ERROR 1 |
5 | #define FSCK_WARN 2 | |
efaba7cc | 6 | #define FSCK_IGNORE 3 |
ba002f3b | 7 | |
22410549 | 8 | struct fsck_options; |
ef3ca954 | 9 | struct object; |
22410549 | 10 | |
0282f4dc JS |
11 | void fsck_set_msg_type(struct fsck_options *options, |
12 | const char *msg_id, const char *msg_type); | |
13 | void fsck_set_msg_types(struct fsck_options *options, const char *values); | |
5d477a33 | 14 | int is_valid_msg_type(const char *msg_id, const char *msg_type); |
0282f4dc | 15 | |
355885d5 MK |
16 | /* |
17 | * callback function for fsck_walk | |
18 | * type is the expected type of the object or OBJ_ANY | |
19 | * the return value is: | |
20 | * 0 everything OK | |
21 | * <0 error signaled and abort | |
22 | * >0 error signaled and do not abort | |
23 | */ | |
22410549 | 24 | typedef int (*fsck_walk_func)(struct object *obj, int type, void *data, struct fsck_options *options); |
355885d5 | 25 | |
ba002f3b | 26 | /* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */ |
1cd772cc JS |
27 | typedef int (*fsck_error)(struct fsck_options *o, |
28 | struct object *obj, int type, const char *message); | |
ba002f3b | 29 | |
1cd772cc JS |
30 | int fsck_error_function(struct fsck_options *o, |
31 | struct object *obj, int type, const char *message); | |
d6ffc8d7 | 32 | |
22410549 JS |
33 | struct fsck_options { |
34 | fsck_walk_func walk; | |
35 | fsck_error error_func; | |
36 | unsigned strict:1; | |
0282f4dc | 37 | int *msg_type; |
910650d2 | 38 | struct oid_array *skiplist; |
7b35efd7 | 39 | struct decoration *object_names; |
22410549 JS |
40 | }; |
41 | ||
0282f4dc JS |
42 | #define FSCK_OPTIONS_DEFAULT { NULL, fsck_error_function, 0, NULL } |
43 | #define FSCK_OPTIONS_STRICT { NULL, fsck_error_function, 1, NULL } | |
22410549 | 44 | |
355885d5 MK |
45 | /* descend in all linked child objects |
46 | * the return value is: | |
47 | * -1 error in processing the object | |
48 | * <0 return value of the callback, which lead to an abort | |
3ea3c215 | 49 | * >0 return value of the first signaled error >0 (in the case of no other errors) |
355885d5 MK |
50 | * 0 everything OK |
51 | */ | |
22410549 | 52 | int fsck_walk(struct object *obj, void *data, struct fsck_options *options); |
90a398bb JS |
53 | /* If NULL is passed for data, we assume the object is local and read it. */ |
54 | int fsck_object(struct object *obj, void *data, unsigned long size, | |
22410549 | 55 | struct fsck_options *options); |
355885d5 | 56 | |
159e7b08 JK |
57 | /* |
58 | * Some fsck checks are context-dependent, and may end up queued; run this | |
59 | * after completing all fsck_object() calls in order to resolve any remaining | |
60 | * checks. | |
61 | */ | |
62 | int fsck_finish(struct fsck_options *options); | |
63 | ||
355885d5 | 64 | #endif |