Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
ee12272d
Commit
ee12272d
authored
Apr 05, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Global option setters
parent
e183e375
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
6 deletions
+20
-6
include/git2/common.h
+2
-0
src/cache.c
+4
-6
src/cache.h
+3
-0
src/util.c
+11
-0
No files found.
include/git2/common.h
View file @
ee12272d
...
@@ -131,6 +131,8 @@ enum {
...
@@ -131,6 +131,8 @@ enum {
GIT_OPT_SET_MWINDOW_MAPPED_LIMIT
,
GIT_OPT_SET_MWINDOW_MAPPED_LIMIT
,
GIT_OPT_GET_SEARCH_PATH
,
GIT_OPT_GET_SEARCH_PATH
,
GIT_OPT_SET_SEARCH_PATH
,
GIT_OPT_SET_SEARCH_PATH
,
GIT_OPT_SET_CACHE_LIMIT
,
GIT_OPT_ENABLE_CACHING
};
};
/**
/**
...
...
src/cache.c
View file @
ee12272d
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
GIT__USE_OIDMAP
GIT__USE_OIDMAP
bool
git_cache__enabled
=
true
;
size_t
git_cache__max_object_size
[
8
]
=
{
size_t
git_cache__max_object_size
[
8
]
=
{
0
,
/* GIT_OBJ__EXT1 */
0
,
/* GIT_OBJ__EXT1 */
4096
,
/* GIT_OBJ_COMMIT */
4096
,
/* GIT_OBJ_COMMIT */
...
@@ -109,11 +111,7 @@ static void cache_evict_entries(git_cache *cache, size_t evict_count)
...
@@ -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
)
static
bool
cache_should_store
(
git_otype
object_type
,
size_t
object_size
)
{
{
size_t
max_size
=
git_cache__max_object_size
[
object_type
];
size_t
max_size
=
git_cache__max_object_size
[
object_type
];
return
git_cache__enabled
&&
object_size
<
max_size
;
if
(
max_size
==
0
||
object_size
>
max_size
)
return
false
;
return
true
;
}
}
static
void
*
cache_get
(
git_cache
*
cache
,
const
git_oid
*
oid
,
unsigned
int
flags
)
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)
...
@@ -121,7 +119,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
khiter_t
pos
;
khiter_t
pos
;
git_cached_obj
*
entry
=
NULL
;
git_cached_obj
*
entry
=
NULL
;
if
(
git_mutex_lock
(
&
cache
->
lock
)
<
0
)
if
(
!
git_cache__enabled
||
git_mutex_lock
(
&
cache
->
lock
)
<
0
)
return
NULL
;
return
NULL
;
pos
=
kh_get
(
oid
,
cache
->
map
,
oid
);
pos
=
kh_get
(
oid
,
cache
->
map
,
oid
);
...
...
src/cache.h
View file @
ee12272d
...
@@ -20,6 +20,9 @@ enum {
...
@@ -20,6 +20,9 @@ enum {
GIT_CACHE_STORE_PARSED
=
2
GIT_CACHE_STORE_PARSED
=
2
};
};
extern
bool
git_cache__enabled
;
extern
size_t
git_cache__max_object_size
[
8
];
typedef
struct
{
typedef
struct
{
git_oid
oid
;
git_oid
oid
;
int16_t
type
;
int16_t
type
;
...
...
src/util.c
View file @
ee12272d
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <ctype.h>
#include <ctype.h>
#include "posix.h"
#include "posix.h"
#include "fileops.h"
#include "fileops.h"
#include "cache.h"
#ifdef _MSC_VER
#ifdef _MSC_VER
# include <Shlwapi.h>
# include <Shlwapi.h>
...
@@ -93,6 +94,16 @@ int git_libgit2_opts(int key, ...)
...
@@ -93,6 +94,16 @@ int git_libgit2_opts(int key, ...)
if
((
error
=
config_level_to_futils_dir
(
va_arg
(
ap
,
int
)))
>=
0
)
if
((
error
=
config_level_to_futils_dir
(
va_arg
(
ap
,
int
)))
>=
0
)
error
=
git_futils_dirs_set
(
error
,
va_arg
(
ap
,
const
char
*
));
error
=
git_futils_dirs_set
(
error
,
va_arg
(
ap
,
const
char
*
));
break
;
break
;
case
GIT_OPT_SET_CACHE_LIMIT
:
{
git_otype
type
=
(
git_otype
)
va_arg
(
ap
,
int
);
git_cache__max_object_size
[
type
]
=
va_arg
(
ap
,
size_t
);
break
;
}
case
GIT_OPT_ENABLE_CACHING
:
git_cache__enabled
=
va_arg
(
ap
,
int
);
break
;
}
}
va_end
(
ap
);
va_end
(
ap
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment