Wrap config snapshot functions
These allow complex reads to come from the same version of the config.
This commit is contained in:
@@ -223,6 +223,19 @@ class Config(object):
|
|||||||
err = C.git_config_add_file_ondisk(self._config, to_str(path), level, force)
|
err = C.git_config_add_file_ondisk(self._config, to_str(path), level, force)
|
||||||
check_error(err)
|
check_error(err)
|
||||||
|
|
||||||
|
def snapshot(self):
|
||||||
|
"""Create a snapshot from this Config object
|
||||||
|
|
||||||
|
This means that looking up multiple values will use the same version
|
||||||
|
of the configuration files
|
||||||
|
"""
|
||||||
|
|
||||||
|
ccfg = ffi.new('git_config **')
|
||||||
|
err = C.git_config_snapshot(cfg, self._config)
|
||||||
|
check_error(err)
|
||||||
|
|
||||||
|
return Config.from_c(self._repo, ccfg[0])
|
||||||
|
|
||||||
#
|
#
|
||||||
# Methods to parse a string according to the git-config rules
|
# Methods to parse a string according to the git-config rules
|
||||||
#
|
#
|
||||||
|
@@ -255,6 +255,7 @@ typedef struct {
|
|||||||
} git_config_entry;
|
} git_config_entry;
|
||||||
|
|
||||||
int git_repository_config(git_config **out, git_repository *repo);
|
int git_repository_config(git_config **out, git_repository *repo);
|
||||||
|
int git_repository_config_snapshot(git_config **out, git_repository *repo);
|
||||||
void git_config_free(git_config *cfg);
|
void git_config_free(git_config *cfg);
|
||||||
|
|
||||||
int git_config_get_string(const char **out, const git_config *cfg, const char *name);
|
int git_config_get_string(const char **out, const git_config *cfg, const char *name);
|
||||||
@@ -279,6 +280,7 @@ int git_config_multivar_iterator_new(git_config_iterator **out, const git_config
|
|||||||
int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value);
|
int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value);
|
||||||
|
|
||||||
int git_config_new(git_config **out);
|
int git_config_new(git_config **out);
|
||||||
|
int git_config_snapshot(git_config **out, git_config *config);
|
||||||
int git_config_open_ondisk(git_config **out, const char *path);
|
int git_config_open_ondisk(git_config **out, const char *path);
|
||||||
int git_config_find_system(git_buf *out);
|
int git_config_find_system(git_buf *out);
|
||||||
int git_config_find_global(git_buf *out);
|
int git_config_find_global(git_buf *out);
|
||||||
|
@@ -128,6 +128,19 @@ class Repository(_Repository):
|
|||||||
|
|
||||||
return Config.from_c(self, cconfig[0])
|
return Config.from_c(self, cconfig[0])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def config_snapshot(self):
|
||||||
|
"""A snapshot for this repositiory's configuration
|
||||||
|
|
||||||
|
This allows reads over multiple values to use the same version
|
||||||
|
of the configuration files"""
|
||||||
|
|
||||||
|
cconfig = ffi.new('git_config **')
|
||||||
|
err = C.git_repository_config_snapshot(cconfig, self._repo)
|
||||||
|
check_error(err)
|
||||||
|
|
||||||
|
return Config.from_c(self, cconfig[0])
|
||||||
|
|
||||||
#
|
#
|
||||||
# References
|
# References
|
||||||
#
|
#
|
||||||
|
Reference in New Issue
Block a user