]>
Commit | Line | Data |
---|---|---|
355885d5 MK |
1 | #ifndef GIT_FSCK_H |
2 | #define GIT_FSCK_H | |
3 | ||
3b41fb0c RS |
4 | #include "oidset.h" |
5 | ||
ba002f3b MK |
6 | #define FSCK_ERROR 1 |
7 | #define FSCK_WARN 2 | |
efaba7cc | 8 | #define FSCK_IGNORE 3 |
ba002f3b | 9 | |
22410549 | 10 | struct fsck_options; |
ef3ca954 | 11 | struct object; |
22410549 | 12 | |
0282f4dc JS |
13 | void fsck_set_msg_type(struct fsck_options *options, |
14 | const char *msg_id, const char *msg_type); | |
15 | void fsck_set_msg_types(struct fsck_options *options, const char *values); | |
5d477a33 | 16 | int is_valid_msg_type(const char *msg_id, const char *msg_type); |
0282f4dc | 17 | |
355885d5 MK |
18 | /* |
19 | * callback function for fsck_walk | |
20 | * type is the expected type of the object or OBJ_ANY | |
21 | * the return value is: | |
22 | * 0 everything OK | |
23 | * <0 error signaled and abort | |
24 | * >0 error signaled and do not abort | |
25 | */ | |
22410549 | 26 | typedef int (*fsck_walk_func)(struct object *obj, int type, void *data, struct fsck_options *options); |
355885d5 | 27 | |
ba002f3b | 28 | /* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */ |
1cd772cc | 29 | typedef int (*fsck_error)(struct fsck_options *o, |
5afc4b1d JK |
30 | const struct object_id *oid, enum object_type object_type, |
31 | int msg_type, const char *message); | |
ba002f3b | 32 | |
1cd772cc | 33 | int fsck_error_function(struct fsck_options *o, |
5afc4b1d JK |
34 | const struct object_id *oid, enum object_type object_type, |
35 | int msg_type, const char *message); | |
d6ffc8d7 | 36 | |
22410549 JS |
37 | struct fsck_options { |
38 | fsck_walk_func walk; | |
39 | fsck_error error_func; | |
40 | unsigned strict:1; | |
0282f4dc | 41 | int *msg_type; |
3b41fb0c | 42 | struct oidset skiplist; |
73390290 | 43 | kh_oid_map_t *object_names; |
22410549 JS |
44 | }; |
45 | ||
3b41fb0c RS |
46 | #define FSCK_OPTIONS_DEFAULT { NULL, fsck_error_function, 0, NULL, OIDSET_INIT } |
47 | #define FSCK_OPTIONS_STRICT { NULL, fsck_error_function, 1, NULL, OIDSET_INIT } | |
22410549 | 48 | |
355885d5 MK |
49 | /* descend in all linked child objects |
50 | * the return value is: | |
51 | * -1 error in processing the object | |
52 | * <0 return value of the callback, which lead to an abort | |
3ea3c215 | 53 | * >0 return value of the first signaled error >0 (in the case of no other errors) |
355885d5 MK |
54 | * 0 everything OK |
55 | */ | |
22410549 | 56 | int fsck_walk(struct object *obj, void *data, struct fsck_options *options); |
23a173a7 JK |
57 | |
58 | /* | |
59 | * Blob objects my pass a NULL data pointer, which indicates they are too large | |
60 | * to fit in memory. All other types must pass a real buffer. | |
61 | */ | |
90a398bb | 62 | int fsck_object(struct object *obj, void *data, unsigned long size, |
22410549 | 63 | struct fsck_options *options); |
355885d5 | 64 | |
acf9de4c ÆAB |
65 | /* |
66 | * fsck a tag, and pass info about it back to the caller. This is | |
67 | * exposed fsck_object() internals for git-mktag(1). | |
68 | */ | |
69 | int fsck_tag_standalone(const struct object_id *oid, const char *buffer, | |
70 | unsigned long size, struct fsck_options *options, | |
71 | struct object_id *tagged_oid, | |
72 | int *tag_type); | |
73 | ||
159e7b08 JK |
74 | /* |
75 | * Some fsck checks are context-dependent, and may end up queued; run this | |
76 | * after completing all fsck_object() calls in order to resolve any remaining | |
77 | * checks. | |
78 | */ | |
79 | int fsck_finish(struct fsck_options *options); | |
80 | ||
a59cfb32 JK |
81 | /* |
82 | * Subsystem for storing human-readable names for each object. | |
83 | * | |
84 | * If fsck_enable_object_names() has not been called, all other functions are | |
85 | * noops. | |
86 | * | |
87 | * Use fsck_put_object_name() to seed initial names (e.g. from refnames); the | |
88 | * fsck code will extend that while walking trees, etc. | |
89 | * | |
90 | * Use fsck_get_object_name() to get a single name (or NULL if none). Or the | |
91 | * more convenient describe_object(), which always produces an output string | |
92 | * with the oid combined with the name (if any). Note that the return value | |
93 | * points to a rotating array of static buffers, and may be invalidated by a | |
94 | * subsequent call. | |
95 | */ | |
96 | void fsck_enable_object_names(struct fsck_options *options); | |
97 | const char *fsck_get_object_name(struct fsck_options *options, | |
73390290 | 98 | const struct object_id *oid); |
a59cfb32 | 99 | __attribute__((format (printf,3,4))) |
73390290 JK |
100 | void fsck_put_object_name(struct fsck_options *options, |
101 | const struct object_id *oid, | |
a59cfb32 JK |
102 | const char *fmt, ...); |
103 | const char *fsck_describe_object(struct fsck_options *options, | |
73390290 | 104 | const struct object_id *oid); |
a59cfb32 | 105 | |
1f3299fd ÆAB |
106 | /* |
107 | * git_config() callback for use by fsck-y tools that want to support | |
108 | * fsck.<msg> fsck.skipList etc. | |
109 | */ | |
110 | int fsck_config_internal(const char *var, const char *value, void *cb, | |
111 | struct fsck_options *options); | |
112 | ||
355885d5 | 113 | #endif |