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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

--
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux