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
550cd2d7
Commit
550cd2d7
authored
Jul 09, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1716 from arrbee/fix-config-get-multivar
Fix git_config_get_multivar with interleaved missing entries
parents
3eae9467
e4fda954
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
13 deletions
+54
-13
src/config.c
+5
-4
tests-clar/config/multivar.c
+48
-8
tests-clar/resources/config/config11
+1
-1
No files found.
src/config.c
View file @
550cd2d7
...
...
@@ -534,7 +534,7 @@ int git_config_get_multivar(
{
file_internal
*
internal
;
git_config_backend
*
file
;
int
ret
=
GIT_ENOTFOUND
;
int
ret
=
GIT_ENOTFOUND
,
err
;
size_t
i
;
/*
...
...
@@ -547,9 +547,10 @@ int git_config_get_multivar(
continue
;
file
=
internal
->
file
;
ret
=
file
->
get_multivar
(
file
,
name
,
regexp
,
cb
,
payload
);
if
(
ret
<
0
&&
ret
!=
GIT_ENOTFOUND
)
return
ret
;
if
(
!
(
err
=
file
->
get_multivar
(
file
,
name
,
regexp
,
cb
,
payload
)))
ret
=
0
;
else
if
(
err
!=
GIT_ENOTFOUND
)
return
err
;
}
return
(
ret
==
GIT_ENOTFOUND
)
?
config_error_notfound
(
name
)
:
0
;
...
...
tests-clar/config/multivar.c
View file @
550cd2d7
#include "clar_libgit2.h"
static
const
char
*
_name
=
"remote.
fancy
.url"
;
static
const
char
*
_name
=
"remote.
ab
.url"
;
void
test_config_multivar__initialize
(
void
)
{
...
...
@@ -46,20 +46,60 @@ static int cb(const git_config_entry *entry, void *data)
return
0
;
}
static
void
check_get_multivar
(
git_config
*
cfg
,
int
expected
,
int
expected_patterned
)
{
int
n
=
0
;
if
(
expected
>
0
)
{
cl_git_pass
(
git_config_get_multivar
(
cfg
,
_name
,
NULL
,
cb
,
&
n
));
cl_assert_equal_i
(
expected
,
n
);
}
else
{
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_config_get_multivar
(
cfg
,
_name
,
NULL
,
cb
,
&
n
));
}
n
=
0
;
if
(
expected_patterned
>
0
)
{
cl_git_pass
(
git_config_get_multivar
(
cfg
,
_name
,
"example"
,
cb
,
&
n
));
cl_assert_equal_i
(
expected_patterned
,
n
);
}
else
{
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_config_get_multivar
(
cfg
,
_name
,
"example"
,
cb
,
&
n
));
}
}
void
test_config_multivar__get
(
void
)
{
git_config
*
cfg
;
int
n
;
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
"config/config11"
));
check_get_multivar
(
cfg
,
2
,
1
);
n
=
0
;
cl_git_pass
(
git_config_
get_multivar
(
cfg
,
_name
,
NULL
,
cb
,
&
n
));
c
l_assert
(
n
==
2
);
/* add another that has the _name entry */
cl_git_pass
(
git_config_
add_file_ondisk
(
cfg
,
"config/config9"
,
GIT_CONFIG_LEVEL_SYSTEM
,
1
));
c
heck_get_multivar
(
cfg
,
3
,
2
);
n
=
0
;
cl_git_pass
(
git_config_get_multivar
(
cfg
,
_name
,
"example"
,
cb
,
&
n
));
cl_assert
(
n
==
1
);
/* add another that does not have the _name entry */
cl_git_pass
(
git_config_add_file_ondisk
(
cfg
,
"config/config0"
,
GIT_CONFIG_LEVEL_GLOBAL
,
1
));
check_get_multivar
(
cfg
,
3
,
2
);
/* add another that does not have the _name entry at the end */
cl_git_pass
(
git_config_add_file_ondisk
(
cfg
,
"config/config1"
,
GIT_CONFIG_LEVEL_APP
,
1
));
check_get_multivar
(
cfg
,
3
,
2
);
/* drop original file */
cl_git_pass
(
git_config_add_file_ondisk
(
cfg
,
"config/config2"
,
GIT_CONFIG_LEVEL_LOCAL
,
1
));
check_get_multivar
(
cfg
,
1
,
1
);
/* drop other file with match */
cl_git_pass
(
git_config_add_file_ondisk
(
cfg
,
"config/config3"
,
GIT_CONFIG_LEVEL_SYSTEM
,
1
));
check_get_multivar
(
cfg
,
0
,
0
);
/* reload original file (add different place in order) */
cl_git_pass
(
git_config_add_file_ondisk
(
cfg
,
"config/config11"
,
GIT_CONFIG_LEVEL_SYSTEM
,
1
));
check_get_multivar
(
cfg
,
2
,
1
);
git_config_free
(
cfg
);
}
...
...
tests-clar/resources/config/config11
View file @
550cd2d7
[remote "
fancy
"]
[remote "
ab
"]
url = git://github.com/libgit2/libgit2
url = git://git.example.com/libgit2
...
...
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