git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/4] index-pack, unpack-objects: add --not-so-strict for connectivity check

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Mar 31, 2013, 11:09 UTC
Message-ID
<1364728148-7537-4-git-send-email-pclouds@gmail.com>
In-Reply-To
<1364728148-7537-1-git-send-email-pclouds@gmail.com>

--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@gmail.com>
---
 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
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 6 of 35 in “check_everything_connected replacement”
  1. 0/4 check_everything_connected replacementNguyễn Thái Ngọc Duy, Mar 31, 2013
  2. 1/4 fetch-pack: save shallow file before fetching the packNguyễn Thái Ngọc Duy, Mar 31, 2013
  3. Junio C HamanoApr 1, 2013
  4. Duy NguyenApr 5, 2013
  5. 2/4 index-pack: remove dead code (it should never happen)Nguyễn Thái Ngọc Duy, Mar 31, 2013
  6. 3/4 index-pack, unpack-objects: add --not-so-strict for connectivity checkNguyễn Thái Ngọc Duy, Mar 31, 2013
  7. 4/4 Use --not-so-strict on all pack transfer for connectivity checkNguyễn Thái Ngọc Duy, Mar 31, 2013
  8. Junio C HamanoApr 1, 2013
  9. 0/5 check_everything_connected replacementNguyễn Thái Ngọc Duy, May 1, 2013
  10. 1/5 clone: let the user know when check_everything_connected is runNguyễn Thái Ngọc Duy, May 1, 2013
  11. 2/5 fetch-pack: prepare updated shallow file before fetching the packNguyễn Thái Ngọc Duy, May 1, 2013
  12. Junio C HamanoMay 1, 2013
  13. Duy NguyenMay 2, 2013
  14. 3/5 index-pack: remove dead code (it should never happen)Nguyễn Thái Ngọc Duy, May 1, 2013
  15. 4/5 index-pack, unpack-objects: add --not-so-strict for connectivity checkNguyễn Thái Ngọc Duy, May 1, 2013
  16. Junio C HamanoMay 1, 2013
  17. Duy NguyenMay 2, 2013
  18. Junio C HamanoMay 2, 2013
  19. Duy NguyenMay 3, 2013
  20. Junio C HamanoMay 3, 2013
  21. Junio C HamanoMay 3, 2013
  22. Duy NguyenMay 3, 2013
  23. Eric SunshineMay 3, 2013
  24. 5/5 Use --not-so-strict on all pack transfer for connectivity checkNguyễn Thái Ngọc Duy, May 1, 2013
  25. 0/4 check_everything_connected replacementNguyễn Thái Ngọc Duy, May 3, 2013
  26. 1/4 clone: let the user know when check_everything_connected is runNguyễn Thái Ngọc Duy, May 3, 2013
  27. 2/4 fetch-pack: prepare updated shallow file before fetching the packNguyễn Thái Ngọc Duy, May 3, 2013
  28. Eric SunshineMay 3, 2013
  29. Junio C HamanoMay 7, 2013
  30. Duy NguyenMay 26, 2013
  31. 3/4 index-pack: remove dead code (it should never happen)Nguyễn Thái Ngọc Duy, May 3, 2013
  32. 4/4 clone: open a shortcut for connectivity checkNguyễn Thái Ngọc Duy, May 3, 2013
  33. Eric SunshineMay 3, 2013
  34. Junio C HamanoMay 3, 2013
  35. Duy NguyenMay 4, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.