diff options
author | Vicent Martà <vicent@github.com> | 2013-03-26 11:05:57 -0700 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2013-03-26 11:05:57 -0700 |
commit | 0b061b5bfacda1a820d159d9e48521d3da4aa088 (patch) | |
tree | 81e0ffea9d2def0b4834442f4c873b4d727495bc /src | |
parent | 86d24ce40c5ccf8783e156ebe8872aee3b97cc49 (diff) | |
parent | f5e28202cb8d73a444e5a5664420fbe5bec11119 (diff) | |
download | libgit2-0b061b5bfacda1a820d159d9e48521d3da4aa088.tar.gz |
Merge pull request #1436 from schu/opts-cache-size
opts: allow configuration of odb cache size
Diffstat (limited to 'src')
-rw-r--r-- | src/odb.c | 4 | ||||
-rw-r--r-- | src/util.c | 9 |
2 files changed, 12 insertions, 1 deletions
@@ -32,6 +32,8 @@ typedef struct int is_alternate; } backend_internal; +size_t git_odb__cache_size = GIT_DEFAULT_CACHE_SIZE; + static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_depth); int git_odb__format_object_header(char *hdr, size_t n, size_t obj_len, git_otype obj_type) @@ -351,7 +353,7 @@ int git_odb_new(git_odb **out) git_odb *db = git__calloc(1, sizeof(*db)); GITERR_CHECK_ALLOC(db); - if (git_cache_init(&db->cache, GIT_DEFAULT_CACHE_SIZE, &free_odb_object) < 0 || + if (git_cache_init(&db->cache, git_odb__cache_size, &free_odb_object) < 0 || git_vector_init(&db->backends, 4, backend_sort_cmp) < 0) { git__free(db); diff --git a/src/util.c b/src/util.c index f5b4a1d68..44ac1af73 100644 --- a/src/util.c +++ b/src/util.c @@ -38,6 +38,7 @@ int git_libgit2_capabilities() /* Declarations for tuneable settings */ extern size_t git_mwindow__window_size; extern size_t git_mwindow__mapped_limit; +extern size_t git_odb__cache_size; static int config_level_to_futils_dir(int config_level) { @@ -92,6 +93,14 @@ int git_libgit2_opts(int key, ...) if ((error = config_level_to_futils_dir(va_arg(ap, int))) >= 0) error = git_futils_dirs_set(error, va_arg(ap, const char *)); break; + + case GIT_OPT_GET_ODB_CACHE_SIZE: + *(va_arg(ap, size_t *)) = git_odb__cache_size; + break; + + case GIT_OPT_SET_ODB_CACHE_SIZE: + git_odb__cache_size = va_arg(ap, size_t); + break; } va_end(ap); |