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
8a8ea1db
Unverified
Commit
8a8ea1db
authored
Feb 28, 2018
by
Patrick Steinhardt
Committed by
GitHub
Feb 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4552 from libgit2/cmn/config-header-common
Cast less blindly between configuration objects
parents
e8e490b2
9cd0c6f1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
src/config_file.c
+10
-8
No files found.
src/config_file.c
View file @
8a8ea1db
...
@@ -86,14 +86,13 @@ typedef struct {
...
@@ -86,14 +86,13 @@ typedef struct {
/* mutex to coordinate accessing the values */
/* mutex to coordinate accessing the values */
git_mutex
values_mutex
;
git_mutex
values_mutex
;
refcounted_strmap
*
values
;
refcounted_strmap
*
values
;
const
git_repository
*
repo
;
git_config_level_t
level
;
}
diskfile_header
;
}
diskfile_header
;
typedef
struct
{
typedef
struct
{
diskfile_header
header
;
diskfile_header
header
;
git_config_level_t
level
;
const
git_repository
*
repo
;
git_array_t
(
git_config_parser
)
readers
;
git_array_t
(
git_config_parser
)
readers
;
bool
locked
;
bool
locked
;
...
@@ -270,8 +269,8 @@ static int config_open(git_config_backend *cfg, git_config_level_t level, const
...
@@ -270,8 +269,8 @@ static int config_open(git_config_backend *cfg, git_config_level_t level, const
int
res
;
int
res
;
diskfile_backend
*
b
=
(
diskfile_backend
*
)
cfg
;
diskfile_backend
*
b
=
(
diskfile_backend
*
)
cfg
;
b
->
level
=
level
;
b
->
header
.
level
=
level
;
b
->
repo
=
repo
;
b
->
header
.
repo
=
repo
;
if
((
res
=
refcounted_strmap_alloc
(
&
b
->
header
.
values
))
<
0
)
if
((
res
=
refcounted_strmap_alloc
(
&
b
->
header
.
values
))
<
0
)
return
res
;
return
res
;
...
@@ -327,6 +326,9 @@ static int config_refresh(git_config_backend *cfg)
...
@@ -327,6 +326,9 @@ static int config_refresh(git_config_backend *cfg)
int
error
,
modified
;
int
error
,
modified
;
uint32_t
i
;
uint32_t
i
;
if
(
b
->
header
.
parent
.
readonly
)
return
config_error_readonly
();
error
=
config_is_modified
(
&
modified
,
&
b
->
file
);
error
=
config_is_modified
(
&
modified
,
&
b
->
file
);
if
(
error
<
0
&&
error
!=
GIT_ENOTFOUND
)
if
(
error
<
0
&&
error
!=
GIT_ENOTFOUND
)
goto
out
;
goto
out
;
...
@@ -343,7 +345,7 @@ static int config_refresh(git_config_backend *cfg)
...
@@ -343,7 +345,7 @@ static int config_refresh(git_config_backend *cfg)
}
}
git_array_clear
(
b
->
file
.
includes
);
git_array_clear
(
b
->
file
.
includes
);
if
((
error
=
config_read
(
values
->
values
,
b
->
repo
,
&
b
->
file
,
b
->
level
,
0
))
<
0
)
if
((
error
=
config_read
(
values
->
values
,
b
->
header
.
repo
,
&
b
->
file
,
b
->
header
.
level
,
0
))
<
0
)
goto
out
;
goto
out
;
if
((
error
=
git_mutex_lock
(
&
b
->
header
.
values_mutex
))
<
0
)
{
if
((
error
=
git_mutex_lock
(
&
b
->
header
.
values_mutex
))
<
0
)
{
...
@@ -417,13 +419,13 @@ static int config_iterator_new(
...
@@ -417,13 +419,13 @@ static int config_iterator_new(
diskfile_header
*
h
;
diskfile_header
*
h
;
git_config_file_iter
*
it
;
git_config_file_iter
*
it
;
git_config_backend
*
snapshot
;
git_config_backend
*
snapshot
;
diskfile_
backend
*
b
=
(
diskfile_backend
*
)
backend
;
diskfile_
header
*
bh
=
(
diskfile_header
*
)
backend
;
int
error
;
int
error
;
if
((
error
=
config_snapshot
(
&
snapshot
,
backend
))
<
0
)
if
((
error
=
config_snapshot
(
&
snapshot
,
backend
))
<
0
)
return
error
;
return
error
;
if
((
error
=
snapshot
->
open
(
snapshot
,
b
->
level
,
b
->
repo
))
<
0
)
if
((
error
=
snapshot
->
open
(
snapshot
,
b
h
->
level
,
bh
->
repo
))
<
0
)
return
error
;
return
error
;
it
=
git__calloc
(
1
,
sizeof
(
git_config_file_iter
));
it
=
git__calloc
(
1
,
sizeof
(
git_config_file_iter
));
...
...
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