All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 3/5] verify-pack: add --quick
Date: Fri, 30 Jan 2009 03:05:15 -0800	[thread overview]
Message-ID: <1233313517-24208-4-git-send-email-gitster@pobox.com> (raw)
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

  reply	other threads:[~2009-01-30 11:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-30 11:05 [PATCH 0/5] fsck updates Junio C Hamano
2009-01-30 11:05 ` [PATCH 1/5] pack-check.c: minor formatting fix to match coding style Junio C Hamano
2009-01-30 11:05   ` [PATCH 2/5] verify_pack(): allow a quicker verification for a pack with version 2 idx Junio C Hamano
2009-01-30 11:05     ` Junio C Hamano [this message]
2009-01-30 11:05       ` [PATCH 4/5] fsck: three levels of validation Junio C Hamano
2009-01-30 11:05         ` [PATCH 5/5] [squash] fsck: revert --quick to the default and introduce --medium Junio C Hamano
2009-01-30 11:37           ` Kjetil Barvik
2009-01-31 21:45   ` [PATCH 1/5] pack-check.c: minor formatting fix to match coding style Nanako Shiraishi
2009-01-31 22:00     ` Marius Storm-Olsen
2009-02-01  0:52       ` Nanako Shiraishi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1233313517-24208-4-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.