Commit 231f350d91e71e3c171041a64f0d238888fad002

Carlos Martín Nieto 2014-06-06T22:55:34

remote: don't free the remote on delete This was a bad idea. Don't free except in the free function.

diff --git a/include/git2/remote.h b/include/git2/remote.h
index 8d37442..cba57c4 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -618,8 +618,6 @@ GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
 * All remote-tracking branches and configuration settings
 * for the remote will be removed.
 *
-* once deleted, the passed remote object will be freed and invalidated.
-*
 * @param remote A valid remote
 * @return 0 on success, or an error code.
 */
diff --git a/src/remote.c b/src/remote.c
index 827c54f..47b61b1 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -1921,8 +1921,6 @@ int git_remote_delete(git_remote *remote)
 		repo, git_remote_name(remote), NULL)) < 0)
 		return error;
 
-	git_remote_free(remote);
-
 	return 0;
 }
 
diff --git a/tests/network/remote/delete.c b/tests/network/remote/delete.c
index db55b07..664f47a 100644
--- a/tests/network/remote/delete.c
+++ b/tests/network/remote/delete.c
@@ -15,6 +15,7 @@ void test_network_remote_delete__initialize(void)
 
 void test_network_remote_delete__cleanup(void)
 {
+	git_remote_free(_remote);
 	cl_git_sandbox_cleanup();
 }
 
@@ -27,7 +28,6 @@ void test_network_remote_delete__cannot_delete_an_anonymous_remote(void)
 	cl_git_fail(git_remote_delete(remote));
 
 	git_remote_free(remote);
-	git_remote_free(_remote);
 }
 
 void test_network_remote_delete__remove_remote_tracking_branches(void)