Merge pull request #739 from arthurschreiber/fix_remote_connected Fix git_remote_connected
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 47 48 49 50 51 52 53 54 55 56 57 58
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;