diff options
| author | Russell Belfer <rb@github.com> | 2014-05-12 10:04:52 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2014-05-12 10:04:52 -0700 |
| commit | d2c4d1c63d9d5456fcf2cdcd578073d9e7dadc2a (patch) | |
| tree | 70b0341e6e5d4898e8b332b658cc0fb2b29a6271 /src/config.c | |
| parent | e18d5e52e385c0cc2ad8d9d4fdd545517f170a11 (diff) | |
| parent | ac99d86ba5e2a9d2332b7f82737e1231c621dc43 (diff) | |
| download | libgit2-d2c4d1c63d9d5456fcf2cdcd578073d9e7dadc2a.tar.gz | |
Merge pull request #2188 from libgit2/cmn/config-snapshot
Configuration snapshotting
Diffstat (limited to 'src/config.c')
| -rw-r--r-- | src/config.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c index f9d697197..75ffb4000 100644 --- a/src/config.c +++ b/src/config.c @@ -137,6 +137,38 @@ int git_config_open_ondisk(git_config **out, const char *path) return error; } +int git_config_snapshot(git_config **out, git_config *in) +{ + int error; + size_t i; + file_internal *internal; + git_config *config; + + *out = NULL; + + if (git_config_new(&config) < 0) + return -1; + + git_vector_foreach(&in->files, i, internal) { + git_config_backend *b; + + if ((error = internal->file->snapshot(&b, internal->file)) < 0) + goto on_error; + + if ((error = git_config_add_backend(config, b, internal->level, 0)) < 0) { + b->free(b); + goto on_error; + } + } + + *out = config; + return error; + +on_error: + git_config_free(config); + return error; +} + static int find_internal_file_by_level( file_internal **internal_out, const git_config *cfg, |
