Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2013-04-06 00:48:39 +0400
committerVicent Marti <tanoku@gmail.com>2013-04-22 18:50:51 +0400
commitee12272d170d6a9d60f13d6de6129f56bfb2fbf6 (patch)
tree9a7d1945b9b85a70ed88a80649e2b27213314fee /src/cache.c
parente183e375b83044d7852b8253553c4f782d73c140 (diff)
Global option setters
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/cache.c b/src/cache.c
index 9f3290f01..f8cddeaca 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -17,6 +17,8 @@
GIT__USE_OIDMAP
+bool git_cache__enabled = true;
+
size_t git_cache__max_object_size[8] = {
0, /* GIT_OBJ__EXT1 */
4096, /* GIT_OBJ_COMMIT */
@@ -109,11 +111,7 @@ static void cache_evict_entries(git_cache *cache, size_t evict_count)
static bool cache_should_store(git_otype object_type, size_t object_size)
{
size_t max_size = git_cache__max_object_size[object_type];
-
- if (max_size == 0 || object_size > max_size)
- return false;
-
- return true;
+ return git_cache__enabled && object_size < max_size;
}
static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
@@ -121,7 +119,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
khiter_t pos;
git_cached_obj *entry = NULL;
- if (git_mutex_lock(&cache->lock) < 0)
+ if (!git_cache__enabled || git_mutex_lock(&cache->lock) < 0)
return NULL;
pos = kh_get(oid, cache->map, oid);