path: root/builtin/unpack-objects.c
diff options
authorJohannes Schindelin <>2015-06-22 15:25:00 (GMT)
committerJunio C Hamano <>2015-06-22 17:23:32 (GMT)
commit22410549fc71b3973a61666f82b7c76317da5df0 (patch)
tree8fb9454b35524ff1be9e86424208aae8bc9d7f51 /builtin/unpack-objects.c
parent5b1d901c0173b41010856e30776c92d02987ea25 (diff)
fsck: introduce fsck options
Just like the diff machinery, we are about to introduce more settings, therefore it makes sense to carry them around as a (pointer to a) struct containing all of them. Signed-off-by: Johannes Schindelin <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/unpack-objects.c')
1 files changed, 6 insertions, 5 deletions
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index ac66672..6d17040 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -20,6 +20,7 @@ static unsigned char buffer[4096];
static unsigned int offset, len;
static off_t consumed_bytes;
static git_SHA_CTX ctx;
+static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
* When running under --strict mode, objects whose reachability are
@@ -178,7 +179,7 @@ static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)
* that have reachability requirements and calls this function.
* Verify its reachability and validity recursively and write it out.
-static int check_object(struct object *obj, int type, void *data)
+static int check_object(struct object *obj, int type, void *data, struct fsck_options *options)
struct obj_buffer *obj_buf;
@@ -203,10 +204,10 @@ static int check_object(struct object *obj, int type, void *data)
obj_buf = lookup_object_buffer(obj);
if (!obj_buf)
die("Whoops! Cannot find object '%s'", sha1_to_hex(obj->sha1));
- if (fsck_object(obj, obj_buf->buffer, obj_buf->size, 1,
- fsck_error_function))
+ if (fsck_object(obj, obj_buf->buffer, obj_buf->size, &fsck_options))
die("Error in object");
- if (fsck_walk(obj, check_object, NULL))
+ fsck_options.walk = check_object;
+ if (fsck_walk(obj, NULL, &fsck_options))
die("Error on reachable objects of %s", sha1_to_hex(obj->sha1));
write_cached_object(obj, obj_buf);
return 0;
@@ -217,7 +218,7 @@ static void write_rest(void)
unsigned i;
for (i = 0; i < nr_objects; i++) {
if (obj_list[i].obj)
- check_object(obj_list[i].obj, OBJ_ANY, NULL);
+ check_object(obj_list[i].obj, OBJ_ANY, NULL, NULL);