From 35079f507b5287a2a4726cae7753439f753453e2 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 21 Apr 2017 07:31:56 +0000 Subject: odb: add option to turn off hash verification Verifying hashsums of objects we are reading from the ODB may be costly as we have to perform an additional hashsum calculation on the object. Especially when reading large objects, the penalty can be as high as 35%, as can be seen when executing the equivalent of `git cat-file` with and without verification enabled. To mitigate for this, we add a global option for libgit2 which enables the developer to turn off the verification, e.g. when he can be reasonably sure that the objects on disk won't be corrupted. --- src/settings.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/settings.c') diff --git a/src/settings.c b/src/settings.c index 07ac16a8f..169fcd51c 100644 --- a/src/settings.c +++ b/src/settings.c @@ -15,6 +15,7 @@ #include "cache.h" #include "global.h" #include "object.h" +#include "odb.h" #include "refs.h" #include "transports/smart.h" @@ -243,6 +244,10 @@ int git_libgit2_opts(int key, ...) #endif break; + case GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION: + git_odb__strict_hash_verification = (va_arg(ap, int) != 0); + break; + default: giterr_set(GITERR_INVALID, "invalid option key"); error = -1; -- cgit v1.2.1