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 /tests/object | |
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 'tests/object')
-rw-r--r-- | tests/object/lookup.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/object/lookup.c b/tests/object/lookup.c index ed12f917a..277e2e0c0 100644 --- a/tests/object/lookup.c +++ b/tests/object/lookup.c @@ -111,6 +111,11 @@ void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void) /* Verify that lookup fails due to a hashsum mismatch */ cl_git_fail_with(GIT_EMISMATCH, git_object_lookup(&object, g_repo, &oid, GIT_OBJ_COMMIT)); + /* Disable verification and try again */ + cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 0)); + cl_git_pass(git_object_lookup(&object, g_repo, &oid, GIT_OBJ_COMMIT)); + cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 1)); + git_buf_free(&oldpath); git_buf_free(&newpath); } |