remote: don't free the remote on delete This was a bad idea. Don't free except in the free function.
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
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)