From 6ac3b707b14217602152c032a11304757c88612c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 21 Nov 2011 20:48:59 +0100 Subject: [PATCH] Add git_remote_connected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Martín Nieto --- include/git2/remote.h | 10 ++++++++++ src/remote.c | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/include/git2/remote.h b/include/git2/remote.h index 94453db56..87f84f8e0 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -123,6 +123,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 * diff --git a/src/remote.c b/src/remote.c index c59991002..e0c127bd3 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) {