From 7b35efd734e501f9e4692768a8b6aea818c0c93e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 17 Jul 2016 12:59:49 +0200 Subject: fsck_walk(): optionally name objects on the go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If fsck_options->name_objects is initialized, and if it already has name(s) for the object(s) that are to be the starting point(s) for fsck_walk(), then that function will now add names for the objects that were walked. This will be highly useful for teaching git-fsck to identify root causes for broken links, which is the task for the next patch in this series. Note that this patch opts for decorating the objects with plain strings instead of full-blown structs (à la `struct rev_name` in the code of the `git name-rev` command), for several reasons: - the code is much simpler than if it had to work with structs that describe arbitrarily long names such as "master~14^2~5:builtin/am.c", - the string processing is actually quite light-weight compared to the rest of fsck's operation, - the caller of fsck_walk() is expected to provide names for the starting points, and using plain and simple strings is just the easiest way to do that. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- fsck.h | 1 + 1 file changed, 1 insertion(+) (limited to 'fsck.h') diff --git a/fsck.h b/fsck.h index dded84b5f9..26c0d41eab 100644 --- a/fsck.h +++ b/fsck.h @@ -33,6 +33,7 @@ struct fsck_options { unsigned strict:1; int *msg_type; struct sha1_array *skiplist; + struct decoration *object_names; }; #define FSCK_OPTIONS_DEFAULT { NULL, fsck_error_function, 0, NULL } -- cgit v1.2.3 From 1cd772cc4124e43b14231dcaeae8a5dddf4ffdb9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 17 Jul 2016 12:59:57 +0200 Subject: fsck: give the error function a chance to see the fsck_options We will need this in the next commit, where fsck will be taught to optionally name the objects when reporting issues about them. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- fsck.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'fsck.h') diff --git a/fsck.h b/fsck.h index 26c0d41eab..1891c1863b 100644 --- a/fsck.h +++ b/fsck.h @@ -23,9 +23,11 @@ int is_valid_msg_type(const char *msg_id, const char *msg_type); typedef int (*fsck_walk_func)(struct object *obj, int type, void *data, struct fsck_options *options); /* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */ -typedef int (*fsck_error)(struct object *obj, int type, const char *message); +typedef int (*fsck_error)(struct fsck_options *o, + struct object *obj, int type, const char *message); -int fsck_error_function(struct object *obj, int type, const char *message); +int fsck_error_function(struct fsck_options *o, + struct object *obj, int type, const char *message); struct fsck_options { fsck_walk_func walk; -- cgit v1.2.3