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
cfef5fb7
Commit
cfef5fb7
authored
Jun 29, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config: `foreach` now returns variable values too
parent
7376ad99
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
include/git2/config.h
+10
-7
src/config.c
+1
-1
src/config_file.c
+2
-2
No files found.
include/git2/config.h
View file @
cfef5fb7
...
...
@@ -48,7 +48,7 @@ struct git_config_file {
int
(
*
open
)(
struct
git_config_file
*
);
int
(
*
get
)(
struct
git_config_file
*
,
const
char
*
key
,
const
char
**
value
);
int
(
*
set
)(
struct
git_config_file
*
,
const
char
*
key
,
const
char
*
value
);
int
(
*
foreach
)(
struct
git_config_file
*
,
int
(
*
fn
)(
const
char
*
,
void
*
),
void
*
data
);
int
(
*
foreach
)(
struct
git_config_file
*
,
int
(
*
fn
)(
const
char
*
,
const
char
*
,
void
*
),
void
*
data
);
void
(
*
free
)(
struct
git_config_file
*
);
};
...
...
@@ -254,19 +254,22 @@ GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value
GIT_EXTERN
(
int
)
git_config_set_string
(
git_config
*
cfg
,
const
char
*
name
,
const
char
*
value
);
/**
* Perform an operation on each config variable
.
* Perform an operation on each config variable
*
* The callback
is passed a pointer to a config variable name and th
e
*
data pointer passed to this function. As soon as one of the
*
callback functions returns something other than 0, this function
* returns that value.
* The callback
receives the normalized name and value of each variabl
e
*
in the config backend, and the data pointer passed to this function.
*
As soon as one of the callback functions returns something other than 0,
*
this function
returns that value.
*
* @param cfg where to get the variables from
* @param callback the function to call on each variable
* @param data the data to pass to the callback
* @return GIT_SUCCESS or the return value of the callback which didn't return 0
*/
GIT_EXTERN
(
int
)
git_config_foreach
(
git_config
*
cfg
,
int
(
*
callback
)(
const
char
*
,
void
*
data
),
void
*
data
);
GIT_EXTERN
(
int
)
git_config_foreach
(
git_config
*
cfg
,
int
(
*
callback
)(
const
char
*
var_name
,
const
char
*
value
,
void
*
payload
),
void
*
payload
);
/** @} */
GIT_END_DECL
...
...
src/config.c
View file @
cfef5fb7
...
...
@@ -151,7 +151,7 @@ int git_config_add_file(git_config *cfg, git_config_file *file, int priority)
* Loop over all the variables
*/
int
git_config_foreach
(
git_config
*
cfg
,
int
(
*
fn
)(
const
char
*
,
void
*
),
void
*
data
)
int
git_config_foreach
(
git_config
*
cfg
,
int
(
*
fn
)(
const
char
*
,
const
char
*
,
void
*
),
void
*
data
)
{
int
ret
=
GIT_SUCCESS
;
unsigned
int
i
;
...
...
src/config_file.c
View file @
cfef5fb7
...
...
@@ -310,7 +310,7 @@ static void backend_free(git_config_file *_backend)
free
(
backend
);
}
static
int
file_foreach
(
git_config_file
*
backend
,
int
(
*
fn
)(
const
char
*
,
void
*
),
void
*
data
)
static
int
file_foreach
(
git_config_file
*
backend
,
int
(
*
fn
)(
const
char
*
,
const
char
*
,
void
*
),
void
*
data
)
{
int
ret
=
GIT_SUCCESS
;
cvar_t
*
var
;
...
...
@@ -323,7 +323,7 @@ static int file_foreach(git_config_file *backend, int (*fn)(const char *, void *
if
(
ret
<
GIT_SUCCESS
)
return
ret
;
ret
=
fn
(
normalized
,
data
);
ret
=
fn
(
normalized
,
var
->
value
,
data
);
free
(
normalized
);
if
(
ret
)
break
;
...
...
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