7 /* for internal use only */
11 /* "public", fed to e.g. error_func callbacks */
16 #define FOREACH_FSCK_MSG_ID(FUNC) \
18 FUNC(NUL_IN_HEADER, FATAL) \
19 FUNC(UNTERMINATED_HEADER, FATAL) \
21 FUNC(BAD_DATE, ERROR) \
22 FUNC(BAD_DATE_OVERFLOW, ERROR) \
23 FUNC(BAD_EMAIL, ERROR) \
24 FUNC(BAD_NAME, ERROR) \
25 FUNC(BAD_OBJECT_SHA1, ERROR) \
26 FUNC(BAD_PARENT_SHA1, ERROR) \
27 FUNC(BAD_TAG_OBJECT, ERROR) \
28 FUNC(BAD_TIMEZONE, ERROR) \
29 FUNC(BAD_TREE, ERROR) \
30 FUNC(BAD_TREE_SHA1, ERROR) \
31 FUNC(BAD_TYPE, ERROR) \
32 FUNC(DUPLICATE_ENTRIES, ERROR) \
33 FUNC(MISSING_AUTHOR, ERROR) \
34 FUNC(MISSING_COMMITTER, ERROR) \
35 FUNC(MISSING_EMAIL, ERROR) \
36 FUNC(MISSING_NAME_BEFORE_EMAIL, ERROR) \
37 FUNC(MISSING_OBJECT, ERROR) \
38 FUNC(MISSING_SPACE_BEFORE_DATE, ERROR) \
39 FUNC(MISSING_SPACE_BEFORE_EMAIL, ERROR) \
40 FUNC(MISSING_TAG, ERROR) \
41 FUNC(MISSING_TAG_ENTRY, ERROR) \
42 FUNC(MISSING_TREE, ERROR) \
43 FUNC(MISSING_TREE_OBJECT, ERROR) \
44 FUNC(MISSING_TYPE, ERROR) \
45 FUNC(MISSING_TYPE_ENTRY, ERROR) \
46 FUNC(MULTIPLE_AUTHORS, ERROR) \
47 FUNC(TREE_NOT_SORTED, ERROR) \
48 FUNC(UNKNOWN_TYPE, ERROR) \
49 FUNC(ZERO_PADDED_DATE, ERROR) \
50 FUNC(GITMODULES_MISSING, ERROR) \
51 FUNC(GITMODULES_BLOB, ERROR) \
52 FUNC(GITMODULES_LARGE, ERROR) \
53 FUNC(GITMODULES_NAME, ERROR) \
54 FUNC(GITMODULES_SYMLINK, ERROR) \
55 FUNC(GITMODULES_URL, ERROR) \
56 FUNC(GITMODULES_PATH, ERROR) \
57 FUNC(GITMODULES_UPDATE, ERROR) \
58 FUNC(GITATTRIBUTES_MISSING, ERROR) \
59 FUNC(GITATTRIBUTES_LARGE, ERROR) \
60 FUNC(GITATTRIBUTES_LINE_LENGTH, ERROR) \
61 FUNC(GITATTRIBUTES_BLOB, ERROR) \
63 FUNC(EMPTY_NAME, WARN) \
64 FUNC(FULL_PATHNAME, WARN) \
66 FUNC(HAS_DOTDOT, WARN) \
67 FUNC(HAS_DOTGIT, WARN) \
68 FUNC(NULL_SHA1, WARN) \
69 FUNC(ZERO_PADDED_FILEMODE, WARN) \
70 FUNC(NUL_IN_COMMIT, WARN) \
71 /* infos (reported as warnings, but ignored by default) */ \
72 FUNC(BAD_FILEMODE, INFO) \
73 FUNC(GITMODULES_PARSE, INFO) \
74 FUNC(GITIGNORE_SYMLINK, INFO) \
75 FUNC(GITATTRIBUTES_SYMLINK, INFO) \
76 FUNC(MAILMAP_SYMLINK, INFO) \
77 FUNC(BAD_TAG_NAME, INFO) \
78 FUNC(MISSING_TAGGER_ENTRY, INFO) \
79 /* ignored (elevated when requested) */ \
80 FUNC(EXTRA_HEADER_ENTRY, IGNORE)
82 #define MSG_ID(id, msg_type) FSCK_MSG_##id,
84 FOREACH_FSCK_MSG_ID(MSG_ID
)
92 void fsck_set_msg_type_from_ids(struct fsck_options
*options
,
93 enum fsck_msg_id msg_id
,
94 enum fsck_msg_type msg_type
);
95 void fsck_set_msg_type(struct fsck_options
*options
,
96 const char *msg_id
, const char *msg_type
);
97 void fsck_set_msg_types(struct fsck_options
*options
, const char *values
);
98 int is_valid_msg_type(const char *msg_id
, const char *msg_type
);
101 * callback function for fsck_walk
102 * type is the expected type of the object or OBJ_ANY
103 * the return value is:
105 * <0 error signaled and abort
106 * >0 error signaled and do not abort
108 typedef int (*fsck_walk_func
)(struct object
*obj
, enum object_type object_type
,
109 void *data
, struct fsck_options
*options
);
111 /* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */
112 typedef int (*fsck_error
)(struct fsck_options
*o
,
113 const struct object_id
*oid
, enum object_type object_type
,
114 enum fsck_msg_type msg_type
, enum fsck_msg_id msg_id
,
115 const char *message
);
117 int fsck_error_function(struct fsck_options
*o
,
118 const struct object_id
*oid
, enum object_type object_type
,
119 enum fsck_msg_type msg_type
, enum fsck_msg_id msg_id
,
120 const char *message
);
121 int fsck_error_cb_print_missing_gitmodules(struct fsck_options
*o
,
122 const struct object_id
*oid
,
123 enum object_type object_type
,
124 enum fsck_msg_type msg_type
,
125 enum fsck_msg_id msg_id
,
126 const char *message
);
128 struct fsck_options
{
130 fsck_error error_func
;
132 enum fsck_msg_type
*msg_type
;
133 struct oidset skiplist
;
134 struct oidset gitmodules_found
;
135 struct oidset gitmodules_done
;
136 struct oidset gitattributes_found
;
137 struct oidset gitattributes_done
;
138 kh_oid_map_t
*object_names
;
141 #define FSCK_OPTIONS_DEFAULT { \
142 .skiplist = OIDSET_INIT, \
143 .gitmodules_found = OIDSET_INIT, \
144 .gitmodules_done = OIDSET_INIT, \
145 .gitattributes_found = OIDSET_INIT, \
146 .gitattributes_done = OIDSET_INIT, \
147 .error_func = fsck_error_function \
149 #define FSCK_OPTIONS_STRICT { \
151 .gitmodules_found = OIDSET_INIT, \
152 .gitmodules_done = OIDSET_INIT, \
153 .gitattributes_found = OIDSET_INIT, \
154 .gitattributes_done = OIDSET_INIT, \
155 .error_func = fsck_error_function, \
157 #define FSCK_OPTIONS_MISSING_GITMODULES { \
159 .gitmodules_found = OIDSET_INIT, \
160 .gitmodules_done = OIDSET_INIT, \
161 .gitattributes_found = OIDSET_INIT, \
162 .gitattributes_done = OIDSET_INIT, \
163 .error_func = fsck_error_cb_print_missing_gitmodules, \
166 /* descend in all linked child objects
167 * the return value is:
168 * -1 error in processing the object
169 * <0 return value of the callback, which lead to an abort
170 * >0 return value of the first signaled error >0 (in the case of no other errors)
173 int fsck_walk(struct object
*obj
, void *data
, struct fsck_options
*options
);
176 * Blob objects my pass a NULL data pointer, which indicates they are too large
177 * to fit in memory. All other types must pass a real buffer.
179 int fsck_object(struct object
*obj
, void *data
, unsigned long size
,
180 struct fsck_options
*options
);
183 * fsck a tag, and pass info about it back to the caller. This is
184 * exposed fsck_object() internals for git-mktag(1).
186 int fsck_tag_standalone(const struct object_id
*oid
, const char *buffer
,
187 unsigned long size
, struct fsck_options
*options
,
188 struct object_id
*tagged_oid
,
192 * Some fsck checks are context-dependent, and may end up queued; run this
193 * after completing all fsck_object() calls in order to resolve any remaining
196 int fsck_finish(struct fsck_options
*options
);
199 * Subsystem for storing human-readable names for each object.
201 * If fsck_enable_object_names() has not been called, all other functions are
204 * Use fsck_put_object_name() to seed initial names (e.g. from refnames); the
205 * fsck code will extend that while walking trees, etc.
207 * Use fsck_get_object_name() to get a single name (or NULL if none). Or the
208 * more convenient describe_object(), which always produces an output string
209 * with the oid combined with the name (if any). Note that the return value
210 * points to a rotating array of static buffers, and may be invalidated by a
213 void fsck_enable_object_names(struct fsck_options
*options
);
214 const char *fsck_get_object_name(struct fsck_options
*options
,
215 const struct object_id
*oid
);
216 __attribute__((format (printf
,3,4)))
217 void fsck_put_object_name(struct fsck_options
*options
,
218 const struct object_id
*oid
,
219 const char *fmt
, ...);
220 const char *fsck_describe_object(struct fsck_options
*options
,
221 const struct object_id
*oid
);
224 * git_config() callback for use by fsck-y tools that want to support
225 * fsck.<msg> fsck.skipList etc.
227 int git_fsck_config(const char *var
, const char *value
, void *cb
);