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
b085ecbe
Commit
b085ecbe
authored
Mar 28, 2016
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3703 from libgit2/cmn/multivar-set-locked
config: don't special-case multivars that don't exist yet
parents
e89abec6
6f09911c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 additions
and
18 deletions
+1
-18
src/config_file.c
+0
-17
tests/config/multivar.c
+1
-1
No files found.
src/config_file.c
View file @
b085ecbe
...
...
@@ -561,31 +561,15 @@ static int config_set_multivar(
git_config_backend
*
cfg
,
const
char
*
name
,
const
char
*
regexp
,
const
char
*
value
)
{
diskfile_backend
*
b
=
(
diskfile_backend
*
)
cfg
;
refcounted_strmap
*
map
;
git_strmap
*
values
;
char
*
key
;
regex_t
preg
;
int
result
;
khiter_t
pos
;
assert
(
regexp
);
if
((
result
=
git_config__normalize_name
(
name
,
&
key
))
<
0
)
return
result
;
if
((
map
=
refcounted_strmap_take
(
&
b
->
header
))
==
NULL
)
return
-
1
;
values
=
b
->
header
.
values
->
values
;
pos
=
git_strmap_lookup_index
(
values
,
key
);
if
(
!
git_strmap_valid_index
(
values
,
pos
))
{
/* If we don't have it, behave like a normal set */
result
=
config_set
(
cfg
,
name
,
value
);
refcounted_strmap_free
(
map
);
git__free
(
key
);
return
result
;
}
result
=
regcomp
(
&
preg
,
regexp
,
REG_EXTENDED
);
if
(
result
!=
0
)
{
giterr_set_regex
(
&
preg
,
result
);
...
...
@@ -600,7 +584,6 @@ static int config_set_multivar(
result
=
config_refresh
(
cfg
);
out:
refcounted_strmap_free
(
map
);
git__free
(
key
);
regfree
(
&
preg
);
...
...
tests/config/multivar.c
View file @
b085ecbe
...
...
@@ -163,7 +163,7 @@ void test_config_multivar__add_new(void)
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
"config/config11"
));
cl_git_pass
(
git_config_set_multivar
(
cfg
,
var
,
""
,
"variable"
));
cl_git_pass
(
git_config_set_multivar
(
cfg
,
var
,
"
$^
"
,
"variable"
));
n
=
0
;
cl_git_pass
(
git_config_get_multivar_foreach
(
cfg
,
var
,
NULL
,
cb
,
&
n
));
cl_assert_equal_i
(
n
,
1
);
...
...
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