]> git.ipfire.org Git - thirdparty/git.git/blobdiff - fsck.h
The 20th batch
[thirdparty/git.git] / fsck.h
diff --git a/fsck.h b/fsck.h
index e3adf9d91159878ae09b35a9fe12370fdbf85f98..500b4c04d2cbf26fecc0b16ff9b4907fe56b4fc4 100644 (file)
--- a/fsck.h
+++ b/fsck.h
@@ -31,6 +31,8 @@ enum fsck_msg_type {
        FUNC(BAD_NAME, ERROR) \
        FUNC(BAD_OBJECT_SHA1, ERROR) \
        FUNC(BAD_PARENT_SHA1, ERROR) \
        FUNC(BAD_NAME, ERROR) \
        FUNC(BAD_OBJECT_SHA1, ERROR) \
        FUNC(BAD_PARENT_SHA1, ERROR) \
+       FUNC(BAD_REF_FILETYPE, ERROR) \
+       FUNC(BAD_REF_NAME, ERROR) \
        FUNC(BAD_TIMEZONE, ERROR) \
        FUNC(BAD_TREE, ERROR) \
        FUNC(BAD_TREE_SHA1, ERROR) \
        FUNC(BAD_TIMEZONE, ERROR) \
        FUNC(BAD_TREE, ERROR) \
        FUNC(BAD_TREE_SHA1, ERROR) \
@@ -114,29 +116,49 @@ int is_valid_msg_type(const char *msg_id, const char *msg_type);
 typedef int (*fsck_walk_func)(struct object *obj, enum object_type object_type,
                              void *data, struct fsck_options *options);
 
 typedef int (*fsck_walk_func)(struct object *obj, enum object_type object_type,
                              void *data, struct fsck_options *options);
 
-/* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */
+/*
+ * Callback for reporting errors either for objects or refs. The "fsck_report"
+ * is a generic pointer that can be used to pass any information.
+ */
 typedef int (*fsck_error)(struct fsck_options *o,
 typedef int (*fsck_error)(struct fsck_options *o,
-                         const struct object_id *oid, enum object_type object_type,
+                         void *fsck_report,
                          enum fsck_msg_type msg_type, enum fsck_msg_id msg_id,
                          const char *message);
 
                          enum fsck_msg_type msg_type, enum fsck_msg_id msg_id,
                          const char *message);
 
-int fsck_error_function(struct fsck_options *o,
-                       const struct object_id *oid, enum object_type object_type,
-                       enum fsck_msg_type msg_type, enum fsck_msg_id msg_id,
-                       const char *message);
-int fsck_error_cb_print_missing_gitmodules(struct fsck_options *o,
-                                          const struct object_id *oid,
-                                          enum object_type object_type,
-                                          enum fsck_msg_type msg_type,
-                                          enum fsck_msg_id msg_id,
-                                          const char *message);
+int fsck_objects_error_function(struct fsck_options *o,
+                               void *fsck_report,
+                               enum fsck_msg_type msg_type, enum fsck_msg_id msg_id,
+                               const char *message);
+int fsck_objects_error_cb_print_missing_gitmodules(struct fsck_options *o,
+                                                  void *fsck_report,
+                                                  enum fsck_msg_type msg_type,
+                                                  enum fsck_msg_id msg_id,
+                                                  const char *message);
+
+int fsck_refs_error_function(struct fsck_options *options,
+                            void *fsck_report,
+                            enum fsck_msg_type msg_type,
+                            enum fsck_msg_id msg_id,
+                            const char *message);
+
+struct fsck_object_report {
+       const struct object_id *oid;
+       enum object_type object_type;
+};
+
+struct fsck_ref_report {
+       const char *path;
+       const struct object_id *oid;
+       const char *referent;
+};
 
 struct fsck_options {
        fsck_walk_func walk;
        fsck_error error_func;
 
 struct fsck_options {
        fsck_walk_func walk;
        fsck_error error_func;
-       unsigned strict:1;
+       unsigned strict;
+       unsigned verbose;
        enum fsck_msg_type *msg_type;
        enum fsck_msg_type *msg_type;
-       struct oidset skiplist;
+       struct oidset skip_oids;
        struct oidset gitmodules_found;
        struct oidset gitmodules_done;
        struct oidset gitattributes_found;
        struct oidset gitmodules_found;
        struct oidset gitmodules_done;
        struct oidset gitattributes_found;
@@ -145,12 +167,12 @@ struct fsck_options {
 };
 
 #define FSCK_OPTIONS_DEFAULT { \
 };
 
 #define FSCK_OPTIONS_DEFAULT { \
-       .skiplist = OIDSET_INIT, \
+       .skip_oids = OIDSET_INIT, \
        .gitmodules_found = OIDSET_INIT, \
        .gitmodules_done = OIDSET_INIT, \
        .gitattributes_found = OIDSET_INIT, \
        .gitattributes_done = OIDSET_INIT, \
        .gitmodules_found = OIDSET_INIT, \
        .gitmodules_done = OIDSET_INIT, \
        .gitattributes_found = OIDSET_INIT, \
        .gitattributes_done = OIDSET_INIT, \
-       .error_func = fsck_error_function \
+       .error_func = fsck_objects_error_function \
 }
 #define FSCK_OPTIONS_STRICT { \
        .strict = 1, \
 }
 #define FSCK_OPTIONS_STRICT { \
        .strict = 1, \
@@ -158,7 +180,7 @@ struct fsck_options {
        .gitmodules_done = OIDSET_INIT, \
        .gitattributes_found = OIDSET_INIT, \
        .gitattributes_done = OIDSET_INIT, \
        .gitmodules_done = OIDSET_INIT, \
        .gitattributes_found = OIDSET_INIT, \
        .gitattributes_done = OIDSET_INIT, \
-       .error_func = fsck_error_function, \
+       .error_func = fsck_objects_error_function, \
 }
 #define FSCK_OPTIONS_MISSING_GITMODULES { \
        .strict = 1, \
 }
 #define FSCK_OPTIONS_MISSING_GITMODULES { \
        .strict = 1, \
@@ -166,7 +188,10 @@ struct fsck_options {
        .gitmodules_done = OIDSET_INIT, \
        .gitattributes_found = OIDSET_INIT, \
        .gitattributes_done = OIDSET_INIT, \
        .gitmodules_done = OIDSET_INIT, \
        .gitattributes_found = OIDSET_INIT, \
        .gitattributes_done = OIDSET_INIT, \
-       .error_func = fsck_error_cb_print_missing_gitmodules, \
+       .error_func = fsck_objects_error_cb_print_missing_gitmodules, \
+}
+#define FSCK_REFS_OPTIONS_DEFAULT { \
+       .error_func = fsck_refs_error_function, \
 }
 
 /* descend in all linked child objects
 }
 
 /* descend in all linked child objects
@@ -190,7 +215,7 @@ int fsck_object(struct object *obj, void *data, unsigned long size,
  * struct.
  */
 int fsck_buffer(const struct object_id *oid, enum object_type,
  * struct.
  */
 int fsck_buffer(const struct object_id *oid, enum object_type,
-               void *data, unsigned long size,
+               const void *data, unsigned long size,
                struct fsck_options *options);
 
 /*
                struct fsck_options *options);
 
 /*
@@ -209,6 +234,21 @@ int fsck_tag_standalone(const struct object_id *oid, const char *buffer,
  */
 int fsck_finish(struct fsck_options *options);
 
  */
 int fsck_finish(struct fsck_options *options);
 
+/*
+ * Clear the fsck_options struct, freeing any allocated memory.
+ */
+void fsck_options_clear(struct fsck_options *options);
+
+/*
+ * Report an error or warning for refs.
+ */
+__attribute__((format (printf, 4, 5)))
+int fsck_report_ref(struct fsck_options *options,
+                   struct fsck_ref_report *report,
+                   enum fsck_msg_id msg_id,
+                   const char *fmt, ...);
+
+
 /*
  * Subsystem for storing human-readable names for each object.
  *
 /*
  * Subsystem for storing human-readable names for each object.
  *