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
f57cc638
Commit
f57cc638
authored
Mar 24, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2200 from libgit2/cmn/opts-buf
settings: use git_buf for returning strings
parents
0deb534d
6057c4a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
16 deletions
+25
-16
include/git2/common.h
+5
-6
src/settings.c
+14
-6
tests/core/env.c
+6
-4
No files found.
include/git2/common.h
View file @
f57cc638
...
...
@@ -161,12 +161,12 @@ typedef enum {
* >Set the maximum amount of memory that can be mapped at any time
* by the library
*
* * opts(GIT_OPT_GET_SEARCH_PATH, int level,
char *out, size_t len
)
* * opts(GIT_OPT_GET_SEARCH_PATH, int level,
git_buf *buf
)
*
* > Get the search path for a given level of config data. "level" must
* > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`, or
* > `GIT_CONFIG_LEVEL_XDG`. The search path is written to the `out`
* > buffer
up to size `len`. Returns GIT_EBUFS if buffer is too small
.
* > buffer.
*
* * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
*
...
...
@@ -195,7 +195,7 @@ typedef enum {
* > across all repositories before libgit2 starts evicting objects
* > from the cache. This is a soft limit, in that the library might
* > briefly exceed it, but will start aggressively evicting objects
* > from cache when that happens. The default cache size is 256M
b
.
* > from cache when that happens. The default cache size is 256M
B
.
*
* * opts(GIT_OPT_ENABLE_CACHING, int enabled)
*
...
...
@@ -210,11 +210,10 @@ typedef enum {
* > Get the current bytes in cache and the maximum that would be
* > allowed in the cache.
*
* * opts(GIT_OPT_GET_TEMPLATE_PATH,
char *out, size_t len
)
* * opts(GIT_OPT_GET_TEMPLATE_PATH,
git_buf *out
)
*
* > Get the default template path.
* > The path is written to the `out`
* > buffer up to size `len`. Returns GIT_EBUFS if buffer is too small.
* > The path is written to the `out` buffer.
*
* * opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path)
*
...
...
src/settings.c
View file @
f57cc638
...
...
@@ -78,10 +78,14 @@ int git_libgit2_opts(int key, ...)
case
GIT_OPT_GET_SEARCH_PATH
:
if
((
error
=
config_level_to_sysdir
(
va_arg
(
ap
,
int
)))
>=
0
)
{
char
*
out
=
va_arg
(
ap
,
char
*
);
size_t
outlen
=
va_arg
(
ap
,
size_t
)
;
git_buf
*
out
=
va_arg
(
ap
,
git_buf
*
);
const
git_buf
*
tmp
;
error
=
git_sysdir_get_str
(
out
,
outlen
,
error
);
git_buf_sanitize
(
out
);
if
((
error
=
git_sysdir_get
(
&
tmp
,
error
))
<
0
)
break
;
error
=
git_buf_sets
(
out
,
tmp
->
ptr
);
}
break
;
...
...
@@ -113,10 +117,14 @@ int git_libgit2_opts(int key, ...)
case
GIT_OPT_GET_TEMPLATE_PATH
:
{
char
*
out
=
va_arg
(
ap
,
char
*
);
size_t
outlen
=
va_arg
(
ap
,
size_t
);
git_buf
*
out
=
va_arg
(
ap
,
git_buf
*
);
const
git_buf
*
tmp
;
git_buf_sanitize
(
out
);
if
((
error
=
git_sysdir_get
(
&
tmp
,
GIT_SYSDIR_TEMPLATE
))
<
0
)
break
;
error
=
git_
sysdir_get_str
(
out
,
outlen
,
GIT_SYSDIR_TEMPLATE
);
error
=
git_
buf_sets
(
out
,
tmp
->
ptr
);
}
break
;
...
...
tests/core/env.c
View file @
f57cc638
...
...
@@ -218,7 +218,7 @@ void test_core_env__1(void)
static
void
check_global_searchpath
(
const
char
*
path
,
int
position
,
const
char
*
file
,
git_buf
*
temp
)
{
char
out
[
GIT_PATH_MAX
]
;
git_buf
out
=
GIT_BUF_INIT
;
/* build and set new path */
if
(
position
<
0
)
...
...
@@ -233,12 +233,12 @@ static void check_global_searchpath(
/* get path and make sure $PATH expansion worked */
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_GET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_GLOBAL
,
out
,
sizeof
(
out
)
));
GIT_OPT_GET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_GLOBAL
,
&
out
));
if
(
position
<
0
)
cl_assert
(
git__prefixcmp
(
out
,
path
)
==
0
);
cl_assert
(
git__prefixcmp
(
out
.
ptr
,
path
)
==
0
);
else
if
(
position
>
0
)
cl_assert
(
git__suffixcmp
(
out
,
path
)
==
0
);
cl_assert
(
git__suffixcmp
(
out
.
ptr
,
path
)
==
0
);
else
cl_assert_equal_s
(
out
,
path
);
...
...
@@ -250,6 +250,8 @@ static void check_global_searchpath(
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_GLOBAL
,
NULL
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_sysdir_find_global_file
(
temp
,
file
));
git_buf_free
(
&
out
);
}
void
test_core_env__2
(
void
)
...
...
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