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
1e96c9d5
Commit
1e96c9d5
authored
Aug 08, 2013
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config: add _next() and _iterator_free()
Make it look like the refs iterator API.
parent
99dfb538
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
0 deletions
+45
-0
include/git2/config.h
+17
-0
src/config.c
+10
-0
tests-clar/config/multivar.c
+18
-0
No files found.
include/git2/config.h
View file @
1e96c9d5
...
...
@@ -351,6 +351,23 @@ GIT_EXTERN(int) git_config_get_multivar_foreach(const git_config *cfg, const cha
* interested in. Use NULL to indicate all
*/
GIT_EXTERN
(
int
)
git_config_get_multivar
(
git_config_iterator
**
out
,
const
git_config
*
cfg
,
const
char
*
name
,
const
char
*
regexp
);
/**
* Return the current entry and advance the iterator
*
* @param entry pointer to store the entry
* @param iter the iterator
* @return 0 or an error code. GIT_ITEROVER if the iteration has completed
*/
GIT_EXTERN
(
int
)
git_config_next
(
git_config_entry
**
entry
,
git_config_iterator
*
iter
);
/**
* Free a config iterator
*
* @param iter the iterator to free
*/
GIT_EXTERN
(
void
)
git_config_iterator_free
(
git_config_iterator
*
iter
);
/**
* Set the value of an integer config variable in the config file
* with the highest level (usually the local one).
...
...
src/config.c
View file @
1e96c9d5
...
...
@@ -727,6 +727,16 @@ int git_config_set_multivar(git_config *cfg, const char *name, const char *regex
return
file
->
set_multivar
(
file
,
name
,
regexp
,
value
);
}
int
git_config_next
(
git_config_entry
**
entry
,
git_config_iterator
*
iter
)
{
return
iter
->
next
(
entry
,
iter
);
}
void
git_config_iterator_free
(
git_config_iterator
*
iter
)
{
iter
->
free
(
iter
);
}
static
int
git_config__find_file_to_path
(
char
*
out
,
size_t
outlen
,
int
(
*
find
)(
git_buf
*
buf
))
{
...
...
tests-clar/config/multivar.c
View file @
1e96c9d5
...
...
@@ -70,6 +70,22 @@ static void check_get_multivar_foreach(
}
}
static
void
check_get_multivar
(
git_config
*
cfg
,
int
expected
)
{
git_config_iterator
*
iter
;
git_config_entry
*
entry
;
int
n
=
0
;
cl_git_pass
(
git_config_get_multivar
(
&
iter
,
cfg
,
_name
,
NULL
));
while
(
git_config_next
(
&
entry
,
iter
)
==
0
)
n
++
;
cl_assert_equal_i
(
expected
,
n
);
git_config_iterator_free
(
iter
);
}
void
test_config_multivar__get
(
void
)
{
git_config
*
cfg
;
...
...
@@ -101,6 +117,8 @@ void test_config_multivar__get(void)
cl_git_pass
(
git_config_add_file_ondisk
(
cfg
,
"config/config11"
,
GIT_CONFIG_LEVEL_SYSTEM
,
1
));
check_get_multivar_foreach
(
cfg
,
2
,
1
);
check_get_multivar
(
cfg
,
2
);
git_config_free
(
cfg
);
}
...
...
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