Rename remote creation APIs git_remote_add -> git_remote_create git_remote_new -> git_remote_create_inmemory
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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index 8048fd6..f81c4fa 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -76,7 +76,7 @@ int fetch(git_repository *repo, int argc, char **argv)
// Figure out whether it's a named remote or a URL
printf("Fetching %s for repo %p\n", argv[1], repo);
if (git_remote_load(&remote, repo, argv[1]) < 0) {
- if (git_remote_new(&remote, repo, NULL, argv[1], NULL) < 0)
+ if (git_remote_create_inmemory(&remote, repo, NULL, argv[1], NULL) < 0)
return -1;
}
diff --git a/examples/network/ls-remote.c b/examples/network/ls-remote.c
index 62131d4..d3e3ed0 100644
--- a/examples/network/ls-remote.c
+++ b/examples/network/ls-remote.c
@@ -21,7 +21,7 @@ static int use_unnamed(git_repository *repo, const char *url)
// Create an instance of a remote from the URL. The transport to use
// is detected from the URL
- error = git_remote_new(&remote, repo, NULL, url, NULL);
+ error = git_remote_create_inmemory(&remote, repo, NULL, url, NULL);
if (error < 0)
goto cleanup;
diff --git a/include/git2/remote.h b/include/git2/remote.h
index f3b0a94..52404c0 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -42,9 +42,24 @@ typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, voi
*/
/**
+ * Add a remote with the default fetch refspec to the repository's configuration
+ *
+ * @param out the resulting remote
+ * @param repo the repository in which to create the remote
+ * @param name the remote's name
+ * @param url the remote's url
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_remote_create(
+ git_remote **out,
+ git_repository *repo,
+ const char *name,
+ const char *url);
+
+/**
* Create a remote in memory
*
- * Create a remote with the default refspecs in memory. You can use
+ * Create a remote with the given refspec in memory. You can use
* this when you have a URL instead of a remote's name.
*
* The name, when provided, will be checked for validity.
@@ -57,7 +72,12 @@ typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, voi
* @param fetch the fetch refspec to use for this remote. May be NULL for defaults.
* @return 0, GIT_EINVALIDSPEC or an error code
*/
-GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch);
+GIT_EXTERN(int) git_remote_create_inmemory(
+ git_remote **out,
+ git_repository *repo,
+ const char *name,
+ const char *url,
+ const char *fetch);
/**
* Sets the owning repository for the remote. This is only allowed on
@@ -301,17 +321,6 @@ GIT_EXTERN(int) git_remote_supported_url(const char* url);
GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
/**
- * Add a remote with the default fetch refspec to the repository's configuration
- *
- * @param out the resulting remote
- * @param repo the repository in which to create the remote
- * @param name the remote's name
- * @param url the remote's url
- * @return 0 or an error code
- */
-GIT_EXTERN(int) git_remote_add(git_remote **out, git_repository *repo, const char *name, const char *url);
-
-/**
* Choose whether to check the server's certificate (applies to HTTPS only)
*
* @param remote the remote to configure
diff --git a/src/clone.c b/src/clone.c
index fae2458..9c4a5d9 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -267,7 +267,7 @@ static int create_and_configure_origin(
int error;
git_remote *origin = NULL;
- if ((error = git_remote_add(&origin, repo, options->remote_name, url)) < 0)
+ if ((error = git_remote_create(&origin, repo, options->remote_name, url)) < 0)
goto on_error;
git_remote_set_cred_acquire_cb(origin, options->cred_acquire_cb,
diff --git a/src/remote.c b/src/remote.c
index 28ce88a..4a5e144 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -83,7 +83,7 @@ cleanup:
return error;
}
-int git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch)
+int git_remote_create_inmemory(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch)
{
git_remote *remote;
git_buf fetchbuf = GIT_BUF_INIT;
@@ -998,7 +998,7 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
return 0;
}
-int git_remote_add(git_remote **out, git_repository *repo, const char *name, const char *url)
+int git_remote_create(git_remote **out, git_repository *repo, const char *name, const char *url)
{
git_buf buf = GIT_BUF_INIT;
int error;
@@ -1009,7 +1009,7 @@ int git_remote_add(git_remote **out, git_repository *repo, const char *name, con
if (git_buf_printf(&buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0)
return -1;
- if (git_remote_new(out, repo, name, url, git_buf_cstr(&buf)) < 0)
+ if (git_remote_create_inmemory(out, repo, name, url, git_buf_cstr(&buf)) < 0)
goto on_error;
git_buf_free(&buf);
diff --git a/src/repository.c b/src/repository.c
index 10ed12b..ea4be9d 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1140,7 +1140,7 @@ static int repo_init_create_origin(git_repository *repo, const char *url)
int error;
git_remote *remote;
- if (!(error = git_remote_add(&remote, repo, GIT_REMOTE_ORIGIN, url))) {
+ if (!(error = git_remote_create(&remote, repo, GIT_REMOTE_ORIGIN, url))) {
error = git_remote_save(remote);
git_remote_free(remote);
}
diff --git a/tests-clar/network/fetch.c b/tests-clar/network/fetch.c
index e724735..cde4f03 100644
--- a/tests-clar/network/fetch.c
+++ b/tests-clar/network/fetch.c
@@ -42,7 +42,7 @@ static void do_fetch(const char *url, git_remote_autotag_option_t flag, int n)
callbacks.update_tips = update_tips;
counter = 0;
- cl_git_pass(git_remote_add(&remote, _repo, "test", url));
+ cl_git_pass(git_remote_create(&remote, _repo, "test", url));
git_remote_set_callbacks(remote, &callbacks);
git_remote_set_autotag(remote, flag);
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
diff --git a/tests-clar/network/fetchlocal.c b/tests-clar/network/fetchlocal.c
index 018531c..2494924 100644
--- a/tests-clar/network/fetchlocal.c
+++ b/tests-clar/network/fetchlocal.c
@@ -21,7 +21,7 @@ void test_network_fetchlocal__complete(void)
const char *url = cl_git_fixture_url("testrepo.git");
cl_git_pass(git_repository_init(&repo, "foo", true));
- cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
+ cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
cl_git_pass(git_remote_update_tips(origin));
@@ -47,7 +47,7 @@ void test_network_fetchlocal__partial(void)
cl_assert_equal_i(1, (int)refnames.count);
url = cl_git_fixture_url("testrepo.git");
- cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
+ cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
cl_git_pass(git_remote_update_tips(origin));
diff --git a/tests-clar/network/push.c b/tests-clar/network/push.c
index cecb5ba..5f0a80c 100644
--- a/tests-clar/network/push.c
+++ b/tests-clar/network/push.c
@@ -166,7 +166,7 @@ void test_network_push__initialize(void)
_remote = NULL;
if (_remote_url) {
- cl_git_pass(git_remote_add(&_remote, _repo, "test", _remote_url));
+ cl_git_pass(git_remote_create(&_remote, _repo, "test", _remote_url));
git_remote_set_cred_acquire_cb(_remote, cred_acquire_cb, &cred_acquire_called);
record_callbacks_data_clear(&_record_cbs_data);
diff --git a/tests-clar/network/remotelocal.c b/tests-clar/network/remotelocal.c
index 8376b8b..1839679 100644
--- a/tests-clar/network/remotelocal.c
+++ b/tests-clar/network/remotelocal.c
@@ -50,7 +50,7 @@ static void connect_to_local_repository(const char *local_repository)
{
git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
- cl_git_pass(git_remote_new(&remote, repo, NULL, git_buf_cstr(&file_path_buf), NULL));
+ cl_git_pass(git_remote_create_inmemory(&remote, repo, NULL, git_buf_cstr(&file_path_buf), NULL));
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
}
diff --git a/tests-clar/network/remoterename.c b/tests-clar/network/remoterename.c
index bd58231..35d197e 100644
--- a/tests-clar/network/remoterename.c
+++ b/tests-clar/network/remoterename.c
@@ -154,7 +154,7 @@ void test_network_remoterename__renaming_an_inmemory_remote_persists_it(void)
assert_config_entry_existence(_repo, "remote.durable.url", false);
- cl_git_pass(git_remote_new(&remote, _repo, NULL, "git://github.com/libgit2/durable.git", NULL));
+ cl_git_pass(git_remote_create_inmemory(&remote, _repo, NULL, "git://github.com/libgit2/durable.git", NULL));
assert_config_entry_existence(_repo, "remote.durable.url", false);
@@ -176,7 +176,7 @@ void test_network_remoterename__renaming_an_inmemory_nameless_remote_notifies_th
assert_config_entry_existence(_repo, "remote.volatile.url", false);
- cl_git_pass(git_remote_new(
+ cl_git_pass(git_remote_create_inmemory(
&remote,
_repo,
NULL,
diff --git a/tests-clar/network/remotes.c b/tests-clar/network/remotes.c
index 651cbef..15e3b03 100644
--- a/tests-clar/network/remotes.c
+++ b/tests-clar/network/remotes.c
@@ -108,7 +108,7 @@ void test_network_remotes__save(void)
_remote = NULL;
/* Set up the remote and save it to config */
- cl_git_pass(git_remote_new(&_remote, _repo, "upstream", "git://github.com/libgit2/libgit2", NULL));
+ cl_git_pass(git_remote_create_inmemory(&_remote, _repo, "upstream", "git://github.com/libgit2/libgit2", NULL));
cl_git_pass(git_remote_set_fetchspec(_remote, "refs/heads/*:refs/remotes/upstream/*"));
cl_git_pass(git_remote_set_pushspec(_remote, "refs/heads/*:refs/heads/*"));
cl_git_pass(git_remote_set_pushurl(_remote, "git://github.com/libgit2/libgit2_push"));
@@ -229,7 +229,7 @@ void test_network_remotes__add(void)
git_remote_free(_remote);
_remote = NULL;
- cl_git_pass(git_remote_add(&_remote, _repo, "addtest", "http://github.com/libgit2/libgit2"));
+ cl_git_pass(git_remote_create(&_remote, _repo, "addtest", "http://github.com/libgit2/libgit2"));
git_remote_free(_remote);
_remote = NULL;
@@ -248,14 +248,14 @@ void test_network_remotes__cannot_add_a_nameless_remote(void)
cl_assert_equal_i(
GIT_EINVALIDSPEC,
- git_remote_add(&remote, _repo, NULL, "git://github.com/libgit2/libgit2"));
+ git_remote_create(&remote, _repo, NULL, "git://github.com/libgit2/libgit2"));
}
void test_network_remotes__cannot_save_a_nameless_remote(void)
{
git_remote *remote;
- cl_git_pass(git_remote_new(&remote, _repo, NULL, "git://github.com/libgit2/libgit2", NULL));
+ cl_git_pass(git_remote_create_inmemory(&remote, _repo, NULL, "git://github.com/libgit2/libgit2", NULL));
cl_assert_equal_i(GIT_EINVALIDSPEC, git_remote_save(remote));
git_remote_free(remote);
@@ -267,12 +267,12 @@ void test_network_remotes__cannot_add_a_remote_with_an_invalid_name(void)
cl_assert_equal_i(
GIT_EINVALIDSPEC,
- git_remote_add(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2"));
+ git_remote_create(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2"));
cl_assert_equal_p(remote, NULL);
cl_assert_equal_i(
GIT_EINVALIDSPEC,
- git_remote_add(&remote, _repo, "", "git://github.com/libgit2/libgit2"));
+ git_remote_create(&remote, _repo, "", "git://github.com/libgit2/libgit2"));
cl_assert_equal_p(remote, NULL);
}
@@ -282,12 +282,12 @@ void test_network_remotes__cannot_initialize_a_remote_with_an_invalid_name(void)
cl_assert_equal_i(
GIT_EINVALIDSPEC,
- git_remote_new(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2", NULL));
+ git_remote_create_inmemory(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2", NULL));
cl_assert_equal_p(remote, NULL);
cl_assert_equal_i(
GIT_EINVALIDSPEC,
- git_remote_new(&remote, _repo, "", "git://github.com/libgit2/libgit2", NULL));
+ git_remote_create_inmemory(&remote, _repo, "", "git://github.com/libgit2/libgit2", NULL));
cl_assert_equal_p(remote, NULL);
}
@@ -331,7 +331,7 @@ void test_network_remotes__check_structure_version(void)
git_remote_free(_remote);
_remote = NULL;
- cl_git_pass(git_remote_new(&_remote, _repo, NULL, "test-protocol://localhost", NULL));
+ cl_git_pass(git_remote_create_inmemory(&_remote, _repo, NULL, "test-protocol://localhost", NULL));
transport.version = 0;
cl_git_fail(git_remote_set_transport(_remote, &transport));
@@ -350,7 +350,7 @@ void test_network_remotes__dangling(void)
git_remote_free(_remote);
_remote = NULL;
- cl_git_pass(git_remote_new(&_remote, NULL, "upstream", "git://github.com/libgit2/libgit2", NULL));
+ cl_git_pass(git_remote_create_inmemory(&_remote, NULL, "upstream", "git://github.com/libgit2/libgit2", NULL));
cl_git_pass(git_remote_rename(_remote, "newname", NULL, NULL));
cl_assert_equal_s(git_remote_name(_remote), "newname");