Add git_remote_connected Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
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
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 94453db..87f84f8 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -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);
/**
+ * Check whether the remote is connected
+ *
+ * Check whether the remote's underlying transport is connected to the
+ * remote host.
+ *
+ * @return 1 if it's connected, 0 otherwise.
+ */
+GIT_EXTERN(int) git_remote_connected(git_remote *remote);
+
+/**
* Disconnect from the remote
*
* Close the connection to the remote and free the underlying
diff --git a/src/remote.c b/src/remote.c
index c599910..e0c127b 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -267,6 +267,11 @@ int git_remote_update_tips(struct git_remote *remote)
return GIT_SUCCESS;
}
+int git_remote_connected(git_remote *remote)
+{
+ return remote->transport == NULL ? 0 : remote->transport->connected;
+}
+
void git_remote_disconnect(git_remote *remote)
{
if (remote->transport != NULL) {