fsck (receive-pack): allow demoting errors to warnings
[git/git.git] / fsck.h
CommitLineData
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
6
22410549
JS
7struct fsck_options;
8
0282f4dc
JS
9void fsck_set_msg_type(struct fsck_options *options,
10 const char *msg_id, const char *msg_type);
11void fsck_set_msg_types(struct fsck_options *options, const char *values);
5d477a33 12int is_valid_msg_type(const char *msg_id, const char *msg_type);
0282f4dc 13
355885d5
MK
14/*
15 * callback function for fsck_walk
16 * type is the expected type of the object or OBJ_ANY
17 * the return value is:
18 * 0 everything OK
19 * <0 error signaled and abort
20 * >0 error signaled and do not abort
21 */
22410549 22typedef int (*fsck_walk_func)(struct object *obj, int type, void *data, struct fsck_options *options);
355885d5 23
ba002f3b 24/* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */
c99ba492 25typedef int (*fsck_error)(struct object *obj, int type, const char *message);
ba002f3b 26
c99ba492 27int fsck_error_function(struct object *obj, int type, const char *message);
d6ffc8d7 28
22410549
JS
29struct fsck_options {
30 fsck_walk_func walk;
31 fsck_error error_func;
32 unsigned strict:1;
0282f4dc 33 int *msg_type;
22410549
JS
34};
35
0282f4dc
JS
36#define FSCK_OPTIONS_DEFAULT { NULL, fsck_error_function, 0, NULL }
37#define FSCK_OPTIONS_STRICT { NULL, fsck_error_function, 1, NULL }
22410549 38
355885d5
MK
39/* descend in all linked child objects
40 * the return value is:
41 * -1 error in processing the object
42 * <0 return value of the callback, which lead to an abort
3ea3c215 43 * >0 return value of the first signaled error >0 (in the case of no other errors)
355885d5
MK
44 * 0 everything OK
45 */
22410549 46int fsck_walk(struct object *obj, void *data, struct fsck_options *options);
90a398bb
JS
47/* If NULL is passed for data, we assume the object is local and read it. */
48int fsck_object(struct object *obj, void *data, unsigned long size,
22410549 49 struct fsck_options *options);
355885d5
MK
50
51#endif