Merge pull request #2638 from libgit2/cmn/config-refresh-remove config: remove the refresh function and backend field
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
diff --git a/include/git2/config.h b/include/git2/config.h
index 21a5825..a4e20ed 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 85e0d64..9136635 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 8aaf8c5..fb425bb 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 8a0fb65..0f8c244 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 1f73e7e..093e74a 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 58bc690..167814e 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 08cd45b..0000000
--- 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 0f11ae8..067b744 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);
}