Commit 8856849c1c8d7fd4c6c8768902845a2b96c29794

Russell Belfer 2012-06-04T14:31:53

Merge pull request #739 from arthurschreiber/fix_remote_connected Fix git_remote_connected

diff --git a/src/transports/git.c b/src/transports/git.c
index 5baa810..844b350 100644
--- a/src/transports/git.c
+++ b/src/transports/git.c
@@ -417,6 +417,8 @@ static int git_close(git_transport *transport)
 		return -1;
 	}
 
+	t->parent.connected = 0;
+
 #ifdef GIT_WIN32
 	WSACleanup();
 #endif
diff --git a/src/transports/http.c b/src/transports/http.c
index 2a8ebbb..9ea21a6 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -610,6 +610,8 @@ static int http_close(git_transport *transport)
 		return -1;
 	}
 
+	t->parent.connected = 0;
+
 	return 0;
 }
 
diff --git a/src/transports/local.c b/src/transports/local.c
index 000993e..0e1ae37 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -190,6 +190,7 @@ static int local_close(git_transport *transport)
 {
 	transport_local *t = (transport_local *)transport;
 
+	t->parent.connected = 0;
 	git_repository_free(t->repo);
 	t->repo = NULL;
 
diff --git a/tests-clar/network/remotelocal.c b/tests-clar/network/remotelocal.c
index 98abbbe..8cee7ce 100644
--- a/tests-clar/network/remotelocal.c
+++ b/tests-clar/network/remotelocal.c
@@ -90,6 +90,15 @@ static void connect_to_local_repository(const char *local_repository)
 
 }
 
+void test_network_remotelocal__connected(void)
+{
+	connect_to_local_repository(cl_fixture("testrepo.git"));
+	cl_assert(git_remote_connected(remote));
+
+	git_remote_disconnect(remote);
+	cl_assert(!git_remote_connected(remote));
+}
+
 void test_network_remotelocal__retrieve_advertised_references(void)
 {
 	int how_many_refs = 0;