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
de0c4555
Commit
de0c4555
authored
Nov 03, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2679 from jfultz/missing-include
Make config reading continue after hitting a missing include file.
parents
0a629181
ebc13b2b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
6 deletions
+28
-6
src/config_file.c
+12
-6
tests/config/include.c
+16
-0
No files found.
src/config_file.c
View file @
de0c4555
...
...
@@ -1269,7 +1269,7 @@ static int config_parse(git_strmap *values, diskfile_backend *cfg_file, struct r
if
((
result
=
git_path_dirname_r
(
&
path
,
reader
->
file_path
))
<
0
)
break
;
/* We need to know ou
t
index in the array, as the next config_parse call may realloc */
/* We need to know ou
r
index in the array, as the next config_parse call may realloc */
index
=
git_array_size
(
cfg_file
->
readers
)
-
1
;
dir
=
git_buf_detach
(
&
path
);
result
=
included_path
(
&
path
,
dir
,
var
->
entry
->
value
);
...
...
@@ -1280,12 +1280,18 @@ static int config_parse(git_strmap *values, diskfile_backend *cfg_file, struct r
r
->
file_path
=
git_buf_detach
(
&
path
);
git_buf_init
(
&
r
->
buffer
,
0
);
if
((
result
=
git_futils_readbuffer_updated
(
&
r
->
buffer
,
r
->
file_path
,
&
r
->
file_mtime
,
&
r
->
file_size
,
NULL
))
<
0
)
break
;
result
=
git_futils_readbuffer_updated
(
&
r
->
buffer
,
r
->
file_path
,
&
r
->
file_mtime
,
&
r
->
file_size
,
NULL
);
if
(
result
==
0
)
{
result
=
config_parse
(
values
,
cfg_file
,
r
,
level
,
depth
+
1
);
r
=
git_array_get
(
cfg_file
->
readers
,
index
);
}
else
if
(
result
==
GIT_ENOTFOUND
)
{
giterr_clear
();
result
=
0
;
}
result
=
config_parse
(
values
,
cfg_file
,
r
,
level
,
depth
+
1
);
r
=
git_array_get
(
cfg_file
->
readers
,
index
);
git_buf_free
(
&
r
->
buffer
);
if
(
result
<
0
)
...
...
tests/config/include.c
View file @
de0c4555
...
...
@@ -86,3 +86,19 @@ void test_config_include__depth(void)
unlink
(
"a"
);
unlink
(
"b"
);
}
void
test_config_include__missing
(
void
)
{
git_config
*
cfg
;
const
char
*
str
;
cl_git_mkfile
(
"including"
,
"[include]
\n
path = nonexistentfile
\n
[foo]
\n
bar = baz"
);
giterr_clear
();
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
"including"
));
cl_assert
(
giterr_last
()
==
NULL
);
cl_git_pass
(
git_config_get_string
(
&
str
,
cfg
,
"foo.bar"
));
cl_assert_equal_s
(
str
,
"baz"
);
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