From cd460522c516f18a12549626a356960370e3bcc7 Mon Sep 17 00:00:00 2001 From: Tony De La Nuez Date: Mon, 20 Apr 2020 22:16:52 +0000 Subject: odb: Implement option for overriding of default odb backend priority Introduce GIT_OPT_SET_ODB_LOOSE_PRIORITY and GIT_OPT_SET_ODB_PACKED_PRIORITY to allow overriding the default priority values for the default ODB backends. Libgit2 has historically assumed that most objects for long- running operations will be packed, therefore GIT_LOOSE_PRIORITY is set to 1 by default, and GIT_PACKED_PRIORITY to 2. When a client allows libgit2 to set the default backends, they can specify an override for the two priority values in order to change the order in which each ODB backend is accessed. --- src/libgit2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libgit2.c') diff --git a/src/libgit2.c b/src/libgit2.c index f27c9997d..089c83590 100644 --- a/src/libgit2.c +++ b/src/libgit2.c @@ -50,6 +50,8 @@ extern size_t git_mwindow__mapped_limit; extern size_t git_mwindow__file_limit; extern size_t git_indexer__max_objects; extern bool git_disable_pack_keep_file_checks; +extern int git_odb__packed_priority; +extern int git_odb__loose_priority; char *git__user_agent; char *git__ssl_ciphers; @@ -368,6 +370,14 @@ int git_libgit2_opts(int key, ...) git_http__expect_continue = (va_arg(ap, int) != 0); break; + case GIT_OPT_SET_ODB_PACKED_PRIORITY: + git_odb__packed_priority = va_arg(ap, int); + break; + + case GIT_OPT_SET_ODB_LOOSE_PRIORITY: + git_odb__loose_priority = va_arg(ap, int); + break; + default: git_error_set(GIT_ERROR_INVALID, "invalid option key"); error = -1; -- cgit v1.2.1