--not-so-strict only checks if all links from objects in the pack point to real objects (either in current repo, or from the pack itself). It's like check_everything_connected() except that: - it does not follow DAG in order - it can detect incomplete object islands - it seems to be faster than "rev-list --objects --all" On my box, "rev-list --objects --all" takes 34 seconds. index-pack takes 215.25user 8.42system 1:32.31elapsed 242%CPU (0avgtext+0avgdata 1357328maxresident)k 0inputs+1421016outputs (0major+1222987minor)pagefaults 0swaps And index-pack --not-so-strict takes pack 96a4e3befa40bf38eddc2d7c99246a59af4ad55d 229.75user 11.31system 1:42.50elapsed 235%CPU (0avgtext+0avgdata 1876816maxresident)k 0inputs+1421016outputs (0major+1307989minor)pagefaults 0swaps The overhead is about 10 seconds, just 1/3 of rev-list, which makes it in a better position to replace check_everything_connected(). If this holds true for general case, it could reduce fetch time by a little bit. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/index-pack.c | 7 ++++++- builtin/unpack-objects.c | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/builtin/index-pack.c b/builtin/index-pack.c index fdac7c7..3cded32 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -77,6 +77,7 @@ static int nr_threads; static int from_stdin; static int strict; +static int do_fsck_object; static int verbose; static struct progress *progress; @@ -744,7 +745,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, obj = parse_object_buffer(sha1, type, size, buf, &eaten); if (!obj) die(_("invalid %s"), typename(type)); - if (fsck_object(obj, 1, fsck_error_function)) + if (do_fsck_object && + fsck_object(obj, 1, fsck_error_function)) die(_("Error in object")); if (fsck_walk(obj, mark_link, NULL)) die(_("Not all child objects of %s are reachable"), sha1_to_hex(obj->sha1)); @@ -1491,6 +1493,9 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) fix_thin_pack = 1; } else if (!strcmp(arg, "--strict")) { strict = 1; + do_fsck_object = 1; + } else if (!strcmp(arg, "--not-so-strict")) { + strict = 1; } else if (!strcmp(arg, "--verify")) { verify = 1; } else if (!strcmp(arg, "--verify-stat")) { diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 2217d7b..dd0518b 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -12,7 +12,7 @@ #include "decorate.h" #include "fsck.h" -static int dry_run, quiet, recover, has_errors, strict; +static int dry_run, quiet, recover, has_errors, strict, do_fsck_object; static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict] < pack-file"; /* We always read in 4kB chunks. */ @@ -198,7 +198,7 @@ static int check_object(struct object *obj, int type, void *data) return 0; } - if (fsck_object(obj, 1, fsck_error_function)) + if (do_fsck_object && fsck_object(obj, 1, fsck_error_function)) die("Error in object"); if (fsck_walk(obj, check_object, NULL)) die("Error on reachable objects of %s", sha1_to_hex(obj->sha1)); @@ -520,6 +520,11 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix) continue; } if (!strcmp(arg, "--strict")) { + do_fsck_object = 1; + strict = 1; + continue; + } + if (!strcmp(arg, "--not-so-strict")) { strict = 1; continue; } -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html