summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-11-05 11:18:14 +0100
committerGitHub <noreply@github.com>2019-11-05 11:18:14 +0100
commit82d7a114eb56c64da15dc278c90385dd3f83c28c (patch)
tree935f76872889b83a36ac08c8632cc788586b774f
parent45c8d3f410157187e12a27e4ebac359870f1fdf3 (diff)
parentdadbb33b600969319fdc80898d0e4c9ebb16964d (diff)
downloadlibgit2-82d7a114eb56c64da15dc278c90385dd3f83c28c.tar.gz
Merge pull request #5293 from csware/config_snapshot-snapshot
Fix crash if snapshotting a config_snapshot
-rw-r--r--src/config_snapshot.c1
-rw-r--r--tests/config/snapshot.c20
2 files changed, 21 insertions, 0 deletions
diff --git a/src/config_snapshot.c b/src/config_snapshot.c
index 764abe208..e89a13886 100644
--- a/src/config_snapshot.c
+++ b/src/config_snapshot.c
@@ -192,6 +192,7 @@ int git_config_backend_snapshot(git_config_backend **out, git_config_backend *so
backend->parent.get = config_get_readonly;
backend->parent.set = config_set_readonly;
backend->parent.set_multivar = config_set_multivar_readonly;
+ backend->parent.snapshot = git_config_backend_snapshot;
backend->parent.del = config_delete_readonly;
backend->parent.del_multivar = config_delete_multivar_readonly;
backend->parent.iterator = config_iterator_new_readonly;
diff --git a/tests/config/snapshot.c b/tests/config/snapshot.c
index 61562d206..3b90cfe49 100644
--- a/tests/config/snapshot.c
+++ b/tests/config/snapshot.c
@@ -100,3 +100,23 @@ void test_config_snapshot__includes(void)
cl_git_pass(p_unlink("including"));
cl_git_pass(p_unlink("included"));
}
+
+void test_config_snapshot__snapshot(void)
+{
+ git_config *snapshot_snapshot;
+ int i;
+
+ cl_git_mkfile("configfile", "[section]\nkey = 1\n");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "configfile"));
+ cl_git_pass(git_config_snapshot(&snapshot, cfg));
+
+ cl_git_pass(git_config_snapshot(&snapshot_snapshot, snapshot));
+
+ cl_git_pass(git_config_get_int32(&i, snapshot_snapshot, "section.key"));
+ cl_assert_equal_i(i, 1);
+
+ git_config_free(snapshot_snapshot);
+
+ cl_git_pass(p_unlink("configfile"));
+}