diff options
| author | Russell Belfer <rb@github.com> | 2012-10-30 12:10:36 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2012-10-30 12:11:23 -0700 |
| commit | 744cc03e2b6d77712bfcb504c272d2e646da650c (patch) | |
| tree | 6dd5c8cf23e02cf4a5b96800e19dc9749d08cc75 /include/git2/config.h | |
| parent | efde422553e1181933d0bc9d7112740e858a847b (diff) | |
| download | libgit2-744cc03e2b6d77712bfcb504c272d2e646da650c.tar.gz | |
Add git_config_refresh() API to reload config
This adds a new API that allows users to reload the config if the
file has changed on disk. A new config callback function to
refresh the config was added.
The modified time and file size are used to test if the file needs
to be reloaded (and are now stored in the disk backend object).
In writing tests, just using mtime was a problem / race, so I
wanted to check file size as well. To support that, I extended
`git_futils_readbuffer_updated` to optionally check file size in
addition to mtime, and I added a new function `git_filebuf_stats`
to fetch the mtime and size for an open filebuf (so that the
config could be easily refreshed after a write).
Lastly, I moved some similar file checking code for attributes
into filebuf. It is still only being used for attrs, but it
seems potentially reusable, so I thought I'd move it over.
Diffstat (limited to 'include/git2/config.h')
| -rw-r--r-- | include/git2/config.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/git2/config.h b/include/git2/config.h index 67408f90f..e417cb379 100644 --- a/include/git2/config.h +++ b/include/git2/config.h @@ -56,6 +56,7 @@ struct git_config_file { int (*set_multivar)(git_config_file *cfg, const char *name, const char *regexp, const char *value); int (*del)(struct git_config_file *, const char *key); int (*foreach)(struct git_config_file *, const char *, int (*fn)(const git_config_entry *, void *), void *data); + int (*refresh)(struct git_config_file *); void (*free)(struct git_config_file *); }; @@ -243,6 +244,19 @@ GIT_EXTERN(int) git_config_open_level( unsigned int level); /** + * Reload changed config files + * + * A config file may be changed on disk out from under the in-memory + * config object. This function causes us to look for files that have + * been modified since we last loaded them and refresh the config with + * the latest information. + * + * @param cfg The configuration to refresh + * @return 0 or an error code + */ +GIT_EXTERN(int) git_config_refresh(git_config *cfg); + +/** * Free the configuration and its associated memory and files * * @param cfg the configuration to free |
