diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-04-21 07:31:56 +0000 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-04-28 14:05:45 +0200 |
commit | 35079f507b5287a2a4726cae7753439f753453e2 (patch) | |
tree | 65ead793083b46ad4a813d1b488a6f01af451c87 /src/settings.c | |
parent | 28a0741f1ae6f5e1261c8e73854dda69e7a61067 (diff) | |
download | libgit2-35079f507b5287a2a4726cae7753439f753453e2.tar.gz |
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.
Diffstat (limited to 'src/settings.c')
-rw-r--r-- | src/settings.c | 5 |
1 files changed, 5 insertions, 0 deletions
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; |