libgit2/include/git2
Patrick Steinhardt 28a0741f1a odb: verify object hashes
The upstream git.git project verifies objects when looking them up from
disk. This avoids scenarios where objects have somehow become corrupt on
disk, e.g. due to hardware failures or bit flips. While our mantra is
usually to follow upstream behavior, we do not do so in this case, as we
never check hashes of objects we have just read from disk.

To fix this, we create a new error class `GIT_EMISMATCH` which denotes
that we have looked up an object with a hashsum mismatch. `odb_read_1`
will then, after having read the object from its backend, hash the
object and compare the resulting hash to the expected hash. If hashes do
not match, it will return an error.

This obviously introduces another computation of checksums and could
potentially impact performance. Note though that we usually perform I/O
operations directly before doing this computation, and as such the
actual overhead should be drowned out by I/O. Running our test suite
seems to confirm this guess. On a Linux system with best-of-five
timings, we had 21.592s with the check enabled and 21.590s with the
ckeck disabled. Note though that our test suite mostly contains very
small blobs only. It is expected that repositories with bigger blobs may
notice an increased hit by this check.

In addition to a new test, we also had to change the
odb::backend::nonrefreshing test suite, which now triggers a hashsum
mismatch when looking up the commit "deadbeef...". This is expected, as
the fake backend allocated inside of the test will return an empty
object for the OID "deadbeef...", which will obviously not hash back to
"deadbeef..." again. We can simply adjust the hash to equal the hash of
the empty object here to fix this test.
2017-04-28 14:05:45 +02:00
..
sys merge_driver: fix const-correctness for source getters 2017-03-15 11:46:15 +01:00
annotated_commit.h annotated_commit: provide a constructor from a revspec 2015-03-16 16:57:30 +01:00
attr.h Documentation fixes 2014-07-08 10:30:19 +02:00
blame.h blame: use size_t for line counts in git_blame_hunk 2015-12-01 09:02:47 +01:00
blob.h Remove traces of git_blob_create_fromchunks 2016-04-26 11:10:31 +02:00
branch.h branch: implement git_branch_is_checked_out 2017-02-13 11:04:57 +01:00
buffer.h Spelling fixes 2014-12-04 21:06:59 -06:00
checkout.h documentation: improve docs for checkout_head 2016-06-15 15:23:39 -05:00
cherrypick.h Use correct Doxygen trailing comment syntax 2015-02-10 12:44:05 -07:00
clone.h Remove the callbacks struct from the remote 2015-05-13 09:46:35 +02:00
commit.h commit: clear user-provided buffers 2017-02-13 13:50:52 +01:00
common.h Allow to configure default file share mode for opening files 2017-04-03 23:13:00 +01:00
config.h config: add a ProgramData level 2015-10-21 15:11:18 +02:00
cred_helpers.h Escape @ in doc comment 2015-08-29 17:46:34 -06:00
describe.h describe: fix documentation 2016-11-01 17:46:20 +01:00
diff.h diff: treat binary patches with no data special 2016-09-05 12:26:47 -05:00
errors.h odb: verify object hashes 2017-04-28 14:05:45 +02:00
filter.h filter: add docs for streaming filters 2015-07-03 14:36:41 +02:00
global.h global: fix typo in git_libgit2_init description 2017-04-21 07:48:30 +00:00
graph.h Add git_graph_descendant_of. 2014-01-28 19:39:14 +01:00
ignore.h update copyrights 2013-01-08 17:31:27 -06:00
index.h Minor comment fix 2017-02-16 08:40:49 -07:00
indexer.h Don't redefine the same callback types, their signatures may change 2014-04-21 11:28:49 +02:00
inttypes.h Unify whitespaces to tabs 2013-05-15 20:26:55 +08:00
merge.h merge: set default rename threshold 2017-01-01 22:34:43 +00:00
message.h message: don't assume the comment char 2014-05-18 10:06:49 +02:00
net.h doc: add documentation to all the public structs and enums 2014-12-06 03:44:40 +01:00
notes.h note: use a git_buf to return the default namespace 2015-03-17 20:50:02 +01:00
object.h peel: reject bad queries with EINVALIDSPEC 2014-11-22 18:55:22 +01:00
odb_backend.h odb_loose: actually honor the fsync option 2017-02-28 13:27:49 +00:00
odb.h Correct typos that reference a non-existing file 2017-04-03 21:25:53 +09:00
oid.h Update docs for git_oid_fromstrn and p 2017-01-27 14:37:16 -05:00
oidarray.h merge: expose multiple merge bases 2014-07-27 17:17:22 +02:00
pack.h packbuilder: size_t all the things 2016-07-24 15:49:19 -04:00
patch.h patch: minor documentation fix. 2016-10-16 00:43:27 +01:00
pathspec.h pathspec: use C guards in header 2014-06-10 03:53:26 +02:00
proxy.h proxy: fix typo in documentation 2016-11-01 16:55:16 +01:00
rebase.h Fix a few checkout -> rebase typos 2016-02-22 15:41:01 +01:00
refdb.h Move git_reference__alloc to include/git2/sys 2013-04-21 12:52:17 -07:00
reflog.h reflog: constify byindex 2014-09-30 15:44:32 +02:00
refs.h Allow creating copies of git_reference objects. 2016-04-22 10:34:17 -07:00
refspec.h refspec: move to git_buf for outputting strings 2014-01-27 04:44:06 +01:00
remote.h Fix typo in remote.h API 2017-03-20 22:30:37 +09:00
repository.h worktree: implement functions reading HEAD 2017-02-13 11:03:01 +01:00
reset.h Flag checkout_opts in git_reset as optional 2017-02-05 07:12:32 +09:00
revert.h Flag given_opts in git_revert as optional 2017-02-04 17:24:31 +09:00
revparse.h Some documentation improvements 2013-08-28 09:31:32 -07:00
revwalk.h revwalk: update the description for the default sorting 2016-10-06 11:04:55 +02:00
signature.h Introduce git_signature_from_buffer 2016-04-28 12:47:14 -04:00
stash.h Flag optional parameters for apply and pop 2017-02-09 19:12:31 +09:00
status.h diff/status: introduce conflicts 2015-05-28 09:44:02 -04:00
stdint.h msvc: Properly handle inttypes.h/stdint.h 2011-10-05 16:21:16 -04:00
strarray.h Unify whitespaces to tabs 2013-05-15 20:26:55 +08:00
submodule.h Update submodule update opts init as per code review 2016-10-10 09:50:24 +11:00
tag.h git_object_dup: introduce typesafe versions 2016-03-23 17:08:37 -04:00
trace.h Remove trace / add git_diff_perfdata struct + api 2014-05-02 09:21:33 -07:00
transaction.h transaction: fix documentation 2016-11-01 17:49:07 +01:00
transport.h Use proper documentation tags 2017-03-22 06:08:24 +09:00
tree.h parameter 'id' not found in the function declaration 2017-01-23 13:32:34 +01:00
types.h worktree: introduce struct git_worktree 2017-02-13 10:28:15 +01:00
version.h Bump version number to v0.25 2016-11-15 11:15:40 +01:00
worktree.h worktree: implement git_worktree_open_from_repository 2017-03-17 09:26:13 +01:00