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
69177621
Commit
69177621
authored
Nov 29, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deploy git_config_backend version
parent
b81aa2f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
2 deletions
+37
-2
src/config.c
+15
-0
src/config_file.c
+2
-2
tests-clar/config/backend.c
+20
-0
No files found.
src/config.c
View file @
69177621
...
...
@@ -248,6 +248,18 @@ int git_config_open_level(
return
0
;
}
static
bool
config_backend_has_valid_version
(
git_config_backend
*
backend
)
{
if
(
!
backend
)
return
true
;
if
(
backend
->
version
>
0
&&
backend
->
version
<=
GIT_CONFIG_BACKEND_VERSION
)
return
true
;
giterr_set
(
GITERR_INVALID
,
"Invalid version %d for git_config_backend"
,
backend
->
version
);
return
false
;
}
int
git_config_add_backend
(
git_config
*
cfg
,
git_config_backend
*
file
,
...
...
@@ -259,6 +271,9 @@ int git_config_add_backend(
assert
(
cfg
&&
file
);
if
(
!
config_backend_has_valid_version
(
file
))
return
-
1
;
if
((
result
=
file
->
open
(
file
,
level
))
<
0
)
return
result
;
...
...
src/config_file.c
View file @
69177621
...
...
@@ -545,10 +545,10 @@ int git_config_file__ondisk(git_config_backend **out, const char *path)
{
diskfile_backend
*
backend
;
backend
=
git__
malloc
(
sizeof
(
diskfile_backend
));
backend
=
git__
calloc
(
1
,
sizeof
(
diskfile_backend
));
GITERR_CHECK_ALLOC
(
backend
);
memset
(
backend
,
0x0
,
sizeof
(
diskfile_backend
))
;
backend
->
parent
.
version
=
GIT_CONFIG_BACKEND_VERSION
;
backend
->
file_path
=
git__strdup
(
path
);
GITERR_CHECK_ALLOC
(
backend
->
file_path
);
...
...
tests-clar/config/backend.c
0 → 100644
View file @
69177621
#include "clar_libgit2.h"
void
test_config_backend__checks_version
(
void
)
{
git_config
*
cfg
;
git_config_backend
backend
=
GIT_CONFIG_BACKEND_INIT
;
backend
.
version
=
1024
;
const
git_error
*
err
;
cl_git_pass
(
git_config_new
(
&
cfg
));
cl_git_fail
(
git_config_add_backend
(
cfg
,
&
backend
,
0
,
false
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
giterr_clear
();
backend
.
version
=
1024
;
cl_git_fail
(
git_config_add_backend
(
cfg
,
&
backend
,
0
,
false
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
}
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