path: root/builtin/unpack-objects.c
diff options
authorJunio C Hamano <>2015-08-03 18:01:18 (GMT)
committerJunio C Hamano <>2015-08-03 18:01:18 (GMT)
commitb2f44feba593ed0c4294a6f9933c8a1b6f190e04 (patch)
tree3b3d19bc7fd5883a4cdf6e0bbf8cf161a63eeab9 /builtin/unpack-objects.c
parentbe9cb560e31c76c00760dadb151b5e3059970586 (diff)
parent1335f732892601368876e0e41c9ea288c2ab18f3 (diff)
Merge branch 'js/fsck-opt'
Allow ignoring fsck errors on specific set of known-to-be-bad objects, and also tweaking warning level of various kinds of non critical breakages reported. * js/fsck-opt: fsck: support ignoring objects in `git fsck` via fsck.skiplist fsck: git receive-pack: support excluding objects from fsck'ing fsck: introduce `git fsck --connectivity-only` fsck: support demoting errors to warnings fsck: document the new receive.fsck.<msg-id> options fsck: allow upgrading fsck warnings to errors fsck: optionally ignore specific fsck issues completely fsck: disallow demoting grave fsck errors to warnings fsck: add a simple test for receive.fsck.<msg-id> fsck: make fsck_tag() warn-friendly fsck: handle multiple authors in commits specially fsck: make fsck_commit() warn-friendly fsck: make fsck_ident() warn-friendly fsck: report the ID of the error/warning fsck (receive-pack): allow demoting errors to warnings fsck: offer a function to demote fsck errors to warnings fsck: provide a function to parse fsck message IDs fsck: introduce identifiers for fsck messages fsck: introduce fsck options
Diffstat (limited to 'builtin/unpack-objects.c')
1 files changed, 11 insertions, 5 deletions
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index ac66672..7cc086f 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);
@@ -529,6 +530,11 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
strict = 1;
+ if (skip_prefix(arg, "--strict=", &arg)) {
+ strict = 1;
+ fsck_set_msg_types(&fsck_options, arg);
+ continue;
+ }
if (starts_with(arg, "--pack_header=")) {
struct pack_header *hdr;
char *c;