diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2014-10-24 16:52:39 -0700 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2014-10-24 16:52:39 -0700 |
commit | d09458f3e9f24afa0689ce90b7d4191872372634 (patch) | |
tree | c45daf219a5c5c1f982ba076c90437795e42f153 | |
parent | 725cd5f29d0c3f7e4019dfc6aacf0fd1843210a9 (diff) | |
parent | 55cb4999720f46eddb97e25e7ddc6ac068dd0bae (diff) | |
download | libgit2-d09458f3e9f24afa0689ce90b7d4191872372634.tar.gz |
Merge pull request #2638 from libgit2/cmn/config-refresh-remove
config: remove the refresh function and backend field
-rw-r--r-- | include/git2/config.h | 14 | ||||
-rw-r--r-- | include/git2/sys/config.h | 1 | ||||
-rw-r--r-- | src/checkout.c | 3 | ||||
-rw-r--r-- | src/config.c | 17 | ||||
-rw-r--r-- | src/config_file.c | 9 | ||||
-rw-r--r-- | tests/config/include.c | 23 | ||||
-rw-r--r-- | tests/config/refresh.c | 64 | ||||
-rw-r--r-- | tests/config/write.c | 5 |
8 files changed, 1 insertions, 135 deletions
diff --git a/include/git2/config.h b/include/git2/config.h index 21a5825a5..a4e20eda8 100644 --- a/include/git2/config.h +++ b/include/git2/config.h @@ -242,20 +242,6 @@ GIT_EXTERN(int) git_config_open_global(git_config **out, git_config *config); */ GIT_EXTERN(int) git_config_snapshot(git_config **out, git_config *config); - -/** - * 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 * diff --git a/include/git2/sys/config.h b/include/git2/sys/config.h index 85e0d6417..9136635ef 100644 --- a/include/git2/sys/config.h +++ b/include/git2/sys/config.h @@ -63,7 +63,6 @@ struct git_config_backend { int (*del)(struct git_config_backend *, const char *key); int (*del_multivar)(struct git_config_backend *, const char *key, const char *regexp); int (*iterator)(git_config_iterator **, struct git_config_backend *); - int (*refresh)(struct git_config_backend *); /** Produce a read-only version of this backend */ int (*snapshot)(struct git_config_backend **, struct git_config_backend *); void (*free)(struct git_config_backend *); diff --git a/src/checkout.c b/src/checkout.c index 8aaf8c5ae..fb425bb0c 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -2038,8 +2038,7 @@ static int checkout_data_init( if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) { git_config *cfg; - if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 || - (error = git_config_refresh(cfg)) < 0) + if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) goto cleanup; /* Get the repository index and reload it (unless we're checking diff --git a/src/config.c b/src/config.c index 8a0fb653c..0f8c24465 100644 --- a/src/config.c +++ b/src/config.c @@ -326,23 +326,6 @@ int git_config_add_backend( return 0; } -int git_config_refresh(git_config *cfg) -{ - int error = 0; - size_t i; - - for (i = 0; i < cfg->files.length && !error; ++i) { - file_internal *internal = git_vector_get(&cfg->files, i); - git_config_backend *file = internal->file; - error = file->refresh(file); - } - - if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL) - git_repository__cvar_cache_clear(GIT_REFCOUNT_OWNER(cfg)); - - return error; -} - /* * Loop over all the variables */ diff --git a/src/config_file.c b/src/config_file.c index 1f73e7e11..093e74a70 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -698,7 +698,6 @@ int git_config_file__ondisk(git_config_backend **out, const char *path) backend->header.parent.del = config_delete; backend->header.parent.del_multivar = config_delete_multivar; backend->header.parent.iterator = config_iterator_new; - backend->header.parent.refresh = config_refresh; backend->header.parent.snapshot = config_snapshot; backend->header.parent.free = backend_free; @@ -744,13 +743,6 @@ static int config_delete_readonly(git_config_backend *cfg, const char *name) return config_error_readonly(); } -static int config_refresh_readonly(git_config_backend *cfg) -{ - GIT_UNUSED(cfg); - - return config_error_readonly(); -} - static void backend_readonly_free(git_config_backend *_backend) { diskfile_backend *backend = (diskfile_backend *)_backend; @@ -804,7 +796,6 @@ int git_config_file__snapshot(git_config_backend **out, diskfile_backend *in) backend->header.parent.del = config_delete_readonly; backend->header.parent.del_multivar = config_delete_multivar_readonly; backend->header.parent.iterator = config_iterator_new; - backend->header.parent.refresh = config_refresh_readonly; backend->header.parent.free = backend_readonly_free; *out = (git_config_backend *)backend; diff --git a/tests/config/include.c b/tests/config/include.c index 58bc690ff..167814e59 100644 --- a/tests/config/include.c +++ b/tests/config/include.c @@ -51,29 +51,6 @@ void test_config_include__homedir(void) cl_sandbox_set_search_path_defaults(); } -void test_config_include__refresh(void) -{ - git_config *cfg; - const char *str; - - cl_fixture_sandbox("config"); - - cl_git_pass(git_config_open_ondisk(&cfg, "config/config-include")); - - cl_git_pass(git_config_get_string(&str, cfg, "foo.bar.baz")); - cl_assert_equal_s(str, "huzzah"); - - /* Change the included file and see if we refresh */ - cl_git_mkfile("config/config-included", "[foo \"bar\"]\nbaz = hurrah"); - cl_git_pass(git_config_refresh(cfg)); - - cl_git_pass(git_config_get_string(&str, cfg, "foo.bar.baz")); - cl_assert_equal_s(str, "hurrah"); - - git_config_free(cfg); - cl_fixture_cleanup("config"); -} - /* We need to pretend that the variables were defined where the file was included */ void test_config_include__ordering(void) { diff --git a/tests/config/refresh.c b/tests/config/refresh.c deleted file mode 100644 index 08cd45b95..000000000 --- a/tests/config/refresh.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "clar_libgit2.h" - -#define TEST_FILE "config.refresh" - -void test_config_refresh__initialize(void) -{ -} - -void test_config_refresh__cleanup(void) -{ - cl_fixture_cleanup(TEST_FILE); -} - -void test_config_refresh__update_value(void) -{ - git_config *cfg; - int32_t v; - - cl_git_mkfile(TEST_FILE, "[section]\n\tvalue = 1\n\n"); - - /* By freeing the config, we make sure we flush the values */ - cl_git_pass(git_config_open_ondisk(&cfg, TEST_FILE)); - - cl_git_pass(git_config_get_int32(&v, cfg, "section.value")); - cl_assert_equal_i(1, v); - - cl_git_rewritefile(TEST_FILE, "[section]\n\tvalue = 10\n\n"); - - cl_git_pass(git_config_refresh(cfg)); - - cl_git_pass(git_config_get_int32(&v, cfg, "section.value")); - cl_assert_equal_i(10, v); - - git_config_free(cfg); -} - -void test_config_refresh__delete_value(void) -{ - git_config *cfg; - int32_t v; - - cl_git_mkfile(TEST_FILE, "[section]\n\tvalue = 1\n\n"); - - /* By freeing the config, we make sure we flush the values */ - cl_git_pass(git_config_open_ondisk(&cfg, TEST_FILE)); - - cl_git_pass(git_config_get_int32(&v, cfg, "section.value")); - cl_assert_equal_i(1, v); - cl_git_fail(git_config_get_int32(&v, cfg, "section.newval")); - - cl_git_rewritefile(TEST_FILE, "[section]\n\tnewval = 10\n\n"); - - cl_git_fail_with(GIT_ENOTFOUND, git_config_get_int32(&v, cfg, "section.value")); - - cl_git_pass(git_config_get_int32(&v, cfg, "section.newval")); - - cl_git_pass(git_config_refresh(cfg)); - - cl_git_fail(git_config_get_int32(&v, cfg, "section.value")); - cl_git_pass(git_config_get_int32(&v, cfg, "section.newval")); - cl_assert_equal_i(10, v); - - git_config_free(cfg); -} diff --git a/tests/config/write.c b/tests/config/write.c index 0f11ae8da..067b7445b 100644 --- a/tests/config/write.c +++ b/tests/config/write.c @@ -340,10 +340,5 @@ void test_config_write__outside_change(void) cl_git_pass(git_config_get_int32(&tmp, cfg, "old.value")); cl_assert_equal_i(6, tmp); - cl_git_pass(git_config_refresh(cfg)); - - cl_git_pass(git_config_get_int32(&tmp, cfg, "old.value")); - cl_assert_equal_i(6, tmp); - git_config_free(cfg); } |