Skip to content

Commit dadbb33

Browse files
committed
Fix crash if snapshotting a config_snapshot
Signed-off-by: Sven Strickroth <email@cs-ware.de>
1 parent 257dd59 commit dadbb33

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/config_snapshot.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ int git_config_backend_snapshot(git_config_backend **out, git_config_backend *so
192192
backend->parent.get = config_get_readonly;
193193
backend->parent.set = config_set_readonly;
194194
backend->parent.set_multivar = config_set_multivar_readonly;
195+
backend->parent.snapshot = git_config_backend_snapshot;
195196
backend->parent.del = config_delete_readonly;
196197
backend->parent.del_multivar = config_delete_multivar_readonly;
197198
backend->parent.iterator = config_iterator_new_readonly;

tests/config/snapshot.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,23 @@ void test_config_snapshot__includes(void)
100100
cl_git_pass(p_unlink("including"));
101101
cl_git_pass(p_unlink("included"));
102102
}
103+
104+
void test_config_snapshot__snapshot(void)
105+
{
106+
git_config *snapshot_snapshot;
107+
int i;
108+
109+
cl_git_mkfile("configfile", "[section]\nkey = 1\n");
110+
111+
cl_git_pass(git_config_open_ondisk(&cfg, "configfile"));
112+
cl_git_pass(git_config_snapshot(&snapshot, cfg));
113+
114+
cl_git_pass(git_config_snapshot(&snapshot_snapshot, snapshot));
115+
116+
cl_git_pass(git_config_get_int32(&i, snapshot_snapshot, "section.key"));
117+
cl_assert_equal_i(i, 1);
118+
119+
git_config_free(snapshot_snapshot);
120+
121+
cl_git_pass(p_unlink("configfile"));
122+
}

0 commit comments

Comments
 (0)