@@ -5,7 +5,7 @@ use std::ptr;
5
5
6
6
use crate :: string_array:: StringArray ;
7
7
use crate :: util:: Binding ;
8
- use crate :: { raw, Buf , ConfigLevel , Error , IntoCString } ;
8
+ use crate :: { raw, Buf , ConfigLevel , Error , IntoCString , ObjectType } ;
9
9
10
10
/// Set the search path for a level of config data. The search path applied to
11
11
/// shared attributes and ignore files, too.
@@ -89,6 +89,25 @@ pub fn enable_caching(enabled: bool) {
89
89
debug_assert ! ( error >= 0 ) ;
90
90
}
91
91
92
+ /// Set the maximum data size for the given type of object to be considered
93
+ /// eligible for caching in memory. Setting to value to zero means that that
94
+ /// type of object will not be cached. Defaults to 0 for [`ObjectType::Blob`]
95
+ /// (i.e. won't cache blobs) and 4k for [`ObjectType::Commit`],
96
+ /// [`ObjectType::Tree`], and [`ObjectType::Tag`].
97
+ pub fn set_cache_object_limit ( kind : ObjectType , size : libc:: size_t ) {
98
+ crate :: init ( ) ;
99
+ let error = unsafe {
100
+ raw:: git_libgit2_opts (
101
+ raw:: GIT_OPT_SET_CACHE_OBJECT_LIMIT as libc:: c_int ,
102
+ kind as libc:: c_int ,
103
+ size,
104
+ )
105
+ } ;
106
+ // This function cannot actually fail, but the function has an error return
107
+ // for other options that can.
108
+ debug_assert ! ( error >= 0 ) ;
109
+ }
110
+
92
111
/// Controls whether or not libgit2 will verify when writing an object that all
93
112
/// objects it references are valid. Enabled by default, but disabling this can
94
113
/// significantly improve performance, at the cost of potentially allowing the
0 commit comments