diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-11-12 10:35:18 +0000 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-06-22 09:52:12 +0200 |
commit | 5ec4aee952ed0db040277c16d1ac015c6e4bee3b (patch) | |
tree | e14337a5736c60c9a7dfc3a9e5ce096c32715358 | |
parent | c16556aaddffc1d663c6403747d793adc0819e0a (diff) | |
download | libgit2-5ec4aee952ed0db040277c16d1ac015c6e4bee3b.tar.gz |
indexer: add ability to select connectivity checks
Right now, we simply turn on connectivity checks in the indexer as soon
as we have access to an object database. But seeing that the
connectivity checks may incur additional overhead, we do want the user
to decide for himself whether he wants to allow those checks.
Furthermore, it might also be desirable to check connectivity in case
where no object database is given at all, e.g. in case where a fully
connected pack file is expected.
Add a flag `verify` to `git_indexer_options` to enable additional
verification checks. Also avoid to query the ODB in case none is given
to allow users to enable checks when they do not have an ODB.
-rw-r--r-- | include/git2/indexer.h | 3 | ||||
-rw-r--r-- | src/indexer.c | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/include/git2/indexer.h b/include/git2/indexer.h index 53a59fc81..94d8785c0 100644 --- a/include/git2/indexer.h +++ b/include/git2/indexer.h @@ -22,6 +22,9 @@ typedef struct git_indexer_options { git_transfer_progress_cb progress_cb; /** progress_cb_payload payload for the progress callback */ void *progress_cb_payload; + + /** Do connectivity checks for the received pack */ + unsigned char verify; } git_indexer_options; #define GIT_INDEXER_OPTIONS_VERSION 1 diff --git a/src/indexer.c b/src/indexer.c index fc9a3bbff..019682c79 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -148,7 +148,7 @@ int git_indexer_new( idx->expected_oids = git_oidmap_alloc(); GITERR_CHECK_ALLOC(idx->expected_oids); - idx->do_verify = !!idx->odb; + idx->do_verify = opts.verify; if (git_repository__fsync_gitdir) idx->do_fsync = 1; @@ -315,7 +315,7 @@ static void add_expected_oid(git_indexer *idx, const git_oid *oid) * because we have already processed it as part of our pack file, we do * not have to expect it. */ - if (!git_odb_exists(idx->odb, oid) && + if ((!idx->odb || !git_odb_exists(idx->odb, oid)) && !git_oidmap_exists(idx->pack->idx_cache, oid) && !git_oidmap_exists(idx->expected_oids, oid)) { git_oid *dup = git__malloc(sizeof(*oid)); @@ -350,7 +350,7 @@ static int check_object_connectivity(git_indexer *idx, const git_rawobj *obj) * Check whether this is a known object. If so, we can just continue as * we assume that the ODB has a complete graph. */ - if (git_odb_exists(idx->odb, &object->cached.oid)) + if (idx->odb && git_odb_exists(idx->odb, &object->cached.oid)) return 0; switch (obj->type) { |