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
2601fcfc
Commit
2601fcfc
authored
Jun 28, 2011
by
Carlos Martín Nieto
Committed by
Vicent Marti
Jul 05, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for deleting a config var
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent
6d4b6097
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletions
+40
-1
include/git2/config.h
+9
-1
tests/resources/config/config9
+1
-0
tests/t15-config.c
+30
-0
No files found.
include/git2/config.h
View file @
2601fcfc
...
...
@@ -254,7 +254,15 @@ 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
* Delete a config variable
*
* @param cfg the configuration
* @param name the variable to delete
*/
GIT_EXTERN
(
int
)
git_config_del
(
git_config
*
cfg
,
const
char
*
name
);
/**
* Perform an operation on each config variable.
*
* The callback receives the normalized name and value of each variable
* in the config backend, and the data pointer passed to this function.
...
...
tests/resources/config/config9
View file @
2601fcfc
[core]
dummy2 = 42
dummy = 1
tests/t15-config.c
View file @
2601fcfc
...
...
@@ -235,6 +235,34 @@ BEGIN_TEST(config11, "fall back to the global config")
git_repository_free
(
repo
);
END_TEST
BEGIN_TEST
(
config12
,
"delete a value"
)
git_config
*
cfg
;
int
i
;
/* By freeing the config, we make sure we flush the values */
must_pass
(
git_config_open_ondisk
(
&
cfg
,
CONFIG_BASE
"/config9"
));
must_pass
(
git_config_set_int
(
cfg
,
"core.dummy"
,
5
));
git_config_free
(
cfg
);
must_pass
(
git_config_open_ondisk
(
&
cfg
,
CONFIG_BASE
"/config9"
));
must_pass
(
git_config_del
(
cfg
,
"core.dummy"
));
git_config_free
(
cfg
);
must_pass
(
git_config_open_ondisk
(
&
cfg
,
CONFIG_BASE
"/config9"
));
must_be_true
(
git_config_get_int
(
cfg
,
"core.dummy"
,
&
i
)
==
GIT_ENOTFOUND
);
must_pass
(
git_config_set_int
(
cfg
,
"core.dummy"
,
1
));
git_config_free
(
cfg
);
END_TEST
BEGIN_TEST
(
config13
,
"can't delete a non-existent value"
)
git_config
*
cfg
;
/* By freeing the config, we make sure we flush the values */
must_pass
(
git_config_open_ondisk
(
&
cfg
,
CONFIG_BASE
"/config9"
));
must_be_true
(
git_config_del
(
cfg
,
"core.imaginary"
)
==
GIT_ENOTFOUND
);
git_config_free
(
cfg
);
END_TEST
BEGIN_SUITE
(
config
)
ADD_TEST
(
config0
);
ADD_TEST
(
config1
);
...
...
@@ -248,4 +276,6 @@ BEGIN_SUITE(config)
ADD_TEST
(
config9
);
ADD_TEST
(
config10
);
ADD_TEST
(
config11
);
ADD_TEST
(
config12
);
ADD_TEST
(
config13
);
END_SUITE
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