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

[PATCH 3/5] verify-pack: add --quick

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 30, 2009, 11:05 UTC
Message-ID
<1233313517-24208-4-git-send-email-gitster@pobox.com>
In-Reply-To
<1233313517-24208-3-git-send-email-gitster@pobox.com>

This teaches "git verify-pack" a new option --quick, to trigger the VERIFY_PACK_QUICK option.

"git fsck" is a more familiar command, and it checks more things at once than "git verify-pack", and the case you do want to use the latter is when really want a deep verification of a single pack. For this reason, I do not think anybody would want to actually use this option, but it was an easy way to benchmark the change.

For a 32M packfile from the git repository on my AMD64X2:
    $ /usr/bin/time ./git-verify-pack $THE_PACKFILE
    22.16user 0.18system 0:22.35elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+44166minor)pagefaults 0swaps
    $ /usr/bin/time ./git-verify-pack --quick $THE_PACKFILE
    0.43user 0.02system 0:00.45elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+11569minor)pagefaults 0swaps
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-verify-pack.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/builtin-verify-pack.c b/builtin-verify-pack.c
index 42ae406..fdc04d1 100644
--- a/builtin-verify-pack.c
+++ b/builtin-verify-pack.c
@@ -54,12 +54,13 @@ static void show_pack_info(struct packed_git *p)
 		       chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
 }
 
-static int verify_one_pack(const char *path, int verbose)
+static int verify_one_pack(const char *path, int verbose, int quick)
 {
 	char arg[PATH_MAX];
 	int len;
 	struct packed_git *pack;
 	int err;
+	unsigned flag = (quick ? VERIFY_PACK_QUICK : 0);
 
 	len = strlcpy(arg, path, PATH_MAX);
 	if (len >= PATH_MAX)
@@ -93,7 +94,7 @@ static int verify_one_pack(const char *path, int verbose)
 		return error("packfile %s not found.", arg);
 
 	install_packed_git(pack);
-	err = verify_pack(pack, 0);
+	err = verify_pack(pack, flag);
 
 	if (verbose) {
 		if (err)
@@ -112,6 +113,7 @@ static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";
 int cmd_verify_pack(int argc, const char **argv, const char *prefix)
 {
 	int err = 0;
+	int quick = 0;
 	int verbose = 0;
 	int no_more_options = 0;
 	int nothing_done = 1;
@@ -121,13 +123,15 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix)
 		if (!no_more_options && argv[1][0] == '-') {
 			if (!strcmp("-v", argv[1]))
 				verbose = 1;
+			else if (!strcmp("--quick", argv[1]))
+				quick = 1;
 			else if (!strcmp("--", argv[1]))
 				no_more_options = 1;
 			else
 				usage(verify_pack_usage);
 		}
 		else {
-			if (verify_one_pack(argv[1], verbose))
+			if (verify_one_pack(argv[1], verbose, quick))
 				err = 1;
 			discard_revindex();
 			nothing_done = 0;
-- 
1.6.1.2.312.g5be3c
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 10 in “fsck updates”
  1. 0/5 fsck updatesJunio C Hamano, Jan 30, 2009
  2. 1/5 pack-check.c: minor formatting fix to match coding styleJunio C Hamano, Jan 30, 2009
  3. 2/5 verify_pack(): allow a quicker verification for a pack with version 2 idxJunio C Hamano, Jan 30, 2009
  4. 3/5 verify-pack: add --quickJunio C Hamano, Jan 30, 2009
  5. 4/5 fsck: three levels of validationJunio C Hamano, Jan 30, 2009
  6. 5/5 [squash] fsck: revert --quick to the default and introduce --mediumJunio C Hamano, Jan 30, 2009
  7. Kjetil BarvikJan 30, 2009
  8. Nanako ShiraishiJan 31, 2009
  9. Marius Storm-OlsenJan 31, 2009
  10. Nanako ShiraishiFeb 1, 2009

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.