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
01ea911b
Unverified
Commit
01ea911b
authored
5 years ago
by
Edward Thomson
Committed by
GitHub
5 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5299 from pks-t/pks/config-mem-snapshots
config_mem: implement support for snapshots
parents
a3d8a437
146e5bf7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
src/config_mem.c
+1
-9
tests/config/snapshot.c
+17
-0
No files found.
src/config_mem.c
View file @
01ea911b
...
...
@@ -170,14 +170,6 @@ static int config_memory_unlock(git_config_backend *backend, int success)
return
config_error_readonly
();
}
static
int
config_memory_snapshot
(
git_config_backend
**
out
,
git_config_backend
*
backend
)
{
GIT_UNUSED
(
out
);
GIT_UNUSED
(
backend
);
git_error_set
(
GIT_ERROR_CONFIG
,
"this backend does not support snapshots"
);
return
-
1
;
}
static
void
config_memory_free
(
git_config_backend
*
_backend
)
{
config_memory_backend
*
backend
=
(
config_memory_backend
*
)
_backend
;
...
...
@@ -219,7 +211,7 @@ int git_config_backend_from_string(git_config_backend **out, const char *cfg, si
backend
->
parent
.
iterator
=
config_memory_iterator
;
backend
->
parent
.
lock
=
config_memory_lock
;
backend
->
parent
.
unlock
=
config_memory_unlock
;
backend
->
parent
.
snapshot
=
config_memory
_snapshot
;
backend
->
parent
.
snapshot
=
git_config_backend
_snapshot
;
backend
->
parent
.
free
=
config_memory_free
;
*
out
=
(
git_config_backend
*
)
backend
;
...
...
This diff is collapsed.
Click to expand it.
tests/config/snapshot.c
View file @
01ea911b
#include "clar_libgit2.h"
#include "config_backend.h"
static
git_config
*
cfg
;
static
git_config
*
snapshot
;
...
...
@@ -120,3 +122,18 @@ void test_config_snapshot__snapshot(void)
cl_git_pass
(
p_unlink
(
"configfile"
));
}
void
test_config_snapshot__snapshot_from_in_memony
(
void
)
{
const
char
*
configuration
=
"[section]
\n
key = 1
\n
"
;
git_config_backend
*
backend
;
int
i
;
cl_git_pass
(
git_config_new
(
&
cfg
));
cl_git_pass
(
git_config_backend_from_string
(
&
backend
,
configuration
,
strlen
(
configuration
)));
cl_git_pass
(
git_config_add_backend
(
cfg
,
backend
,
0
,
NULL
,
0
));
cl_git_pass
(
git_config_snapshot
(
&
snapshot
,
cfg
));
cl_git_pass
(
git_config_get_int32
(
&
i
,
snapshot
,
"section.key"
));
cl_assert_equal_i
(
i
,
1
);
}
This diff is collapsed.
Click to expand it.
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