Commit 4cf01e9a by Carlos Martín Nieto

Add git_remote_disconnect

It can be useful to separate disconnecting from actually destroying
the object.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
parent 0ca7ca3e
......@@ -124,6 +124,16 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headarray *refs);
GIT_EXTERN(int) git_remote_download(char **filename, git_remote *remote);
/**
* Disconnect from the remote
*
* Close the connection to the remote and free the underlying
* transport.
*
* @param remote the remote to disconnect from
*/
GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
/**
* Free the memory associated with a remote
*
* @param remote the remote to free
......
......@@ -267,6 +267,16 @@ int git_remote_update_tips(struct git_remote *remote)
return GIT_SUCCESS;
}
void git_remote_disconnect(git_remote *remote)
{
if (remote->transport != NULL) {
if (remote->transport->connected)
remote->transport->close(remote->transport);
remote->transport->free(remote->transport);
}
}
void git_remote_free(git_remote *remote)
{
if (remote == NULL)
......@@ -278,11 +288,6 @@ void git_remote_free(git_remote *remote)
git__free(remote->push.dst);
git__free(remote->url);
git__free(remote->name);
if (remote->transport != NULL) {
if (remote->transport->connected)
remote->transport->close(remote->transport);
remote->transport->free(remote->transport);
}
git_remote_disconnect(remote);
git__free(remote);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment