Commit a4b6452a6a32ac94c5c616eb4cc9c691d954732e

Carlos Martín Nieto 2015-04-23T06:55:29

remote: remove git_remote_save() It has now become a no-op, so remove the function and all references to it.

diff --git a/include/git2/remote.h b/include/git2/remote.h
index 73440a9..ab14ad4 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -28,8 +28,7 @@ GIT_BEGIN_DECL
 typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload);
 
 /**
- * Add a remote with the default fetch refspec to the repository's configuration.  This
- * calls git_remote_save before returning.
+ * 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
@@ -45,8 +44,7 @@ GIT_EXTERN(int) git_remote_create(
 
 /**
  * Add a remote with the provided fetch refspec (or default if NULL) to the repository's
- * configuration.  This
- * calls git_remote_save before returning.
+ * configuration.
  *
  * @param out the resulting remote
  * @param repo the repository in which to create the remote
@@ -98,17 +96,6 @@ GIT_EXTERN(int) git_remote_create_anonymous(
 GIT_EXTERN(int) git_remote_lookup(git_remote **out, git_repository *repo, const char *name);
 
 /**
- * Save a remote to its repository's configuration
- *
- * One can't save a in-memory remote. Doing so will
- * result in a GIT_EINVALIDSPEC being returned.
- *
- * @param remote the remote to save to config
- * @return 0, GIT_EINVALIDSPEC or an error code
- */
-GIT_EXTERN(int) git_remote_save(const git_remote *remote);
-
-/**
  * Create a copy of an existing remote.  All internal strings are also
  * duplicated. Callbacks are not duplicated.
  *
diff --git a/src/clone.c b/src/clone.c
index c44cf59..8b42ce7 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -279,9 +279,6 @@ static int create_and_configure_origin(
 	if ((error = remote_create(&origin, repo, "origin", url, payload)) < 0)
 		goto on_error;
 
-	if ((error = git_remote_save(origin)) < 0)
-		goto on_error;
-
 	*out = origin;
 	return 0;
 
diff --git a/src/remote.c b/src/remote.c
index f4a2f04..891f0f2 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -302,9 +302,6 @@ int git_remote_create_with_fetchspec(git_remote **out, git_repository *repo, con
 	if (create_internal(&remote, repo, name, url, fetch) < 0)
 		goto on_error;
 
-	if (git_remote_save(remote) < 0)
-		goto on_error;
-
 	*out = remote;
 
 	return 0;
@@ -595,27 +592,6 @@ cleanup:
 	return error;
 }
 
-int git_remote_save(const git_remote *remote)
-{
-	int error;
-	git_config *cfg;
-
-	assert(remote);
-
-	if (!remote->name) {
-		giterr_set(GITERR_INVALID, "Can't save an anonymous remote.");
-		return GIT_EINVALIDSPEC;
-	}
-
-	if ((error = ensure_remote_name_is_valid(remote->name)) < 0)
-		return error;
-
-	if ((error = git_repository_config__weakptr(&cfg, remote->repo)) < 0)
-		return error;
-
-	return error;
-}
-
 const char *git_remote_name(const git_remote *remote)
 {
 	assert(remote);
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index 0da76da..f81c1cc 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -319,18 +319,6 @@ void test_network_remote_remotes__cannot_add_a_nameless_remote(void)
 		git_remote_create(&remote, _repo, NULL, "git://github.com/libgit2/libgit2"));
 }
 
-void test_network_remote_remotes__cannot_save_an_inmemory_remote(void)
-{
-	git_remote *remote;
-
-	cl_git_pass(git_remote_create_anonymous(&remote, _repo, "git://github.com/libgit2/libgit2", NULL));
-
-	cl_assert_equal_p(NULL, git_remote_name(remote));
-
-	cl_git_fail(git_remote_save(remote));
-	git_remote_free(remote);
-}
-
 void test_network_remote_remotes__cannot_add_a_remote_with_an_invalid_name(void)
 {
 	git_remote *remote = NULL;