diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-11-07 15:31:21 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-12-19 13:05:26 -0400 |
commit | 8bc913a29d9c63a0766e13324810c0d69aeb390d (patch) | |
tree | 6d917126dc79052e4d903c76ac17f7d16243f6fa | |
parent | f23dc5b29f1394928a940d7ec447f4bfd53dad1f (diff) | |
download | libgit2-8bc913a29d9c63a0766e13324810c0d69aeb390d.tar.gz |
smart transport: only clear url on hard resetethomson/backport_0278
After creating a transport for a server, we expect to be able to call
`connect`, then invoke subsequent `action` calls. We provide the URL to
these `action` calls, although our built-in transports happen to ignore
it since they've already parsed it into an internal format that they
intend to use (`gitno_connection_data`).
In ca2eb4608243162a13c427e74526b6422d5a6659, we began clearing the URL
field after a connection, meaning that subsequent calls to transport
`action` callbacks would get a NULL URL, which went undetected since the
builtin transports ignore the URL when they're already connected
(instead of re-parsing it into an internal format).
Downstream custom transport implementations (eg, LibGit2Sharp) did
notice this change, however.
Since `reset_stream` is called even when we're not closing the
subtransport, update to only clear the URL when we're closing the
subtransport. This ensures that `action` calls will get the correct URL
information even after a connection.
-rw-r--r-- | src/transports/smart.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/transports/smart.c b/src/transports/smart.c index 5fedd394e..b49e76ee9 100644 --- a/src/transports/smart.c +++ b/src/transports/smart.c @@ -45,14 +45,13 @@ GIT_INLINE(int) git_smart__reset_stream(transport_smart *t, bool close_subtransp t->current_stream = NULL; } - if (t->url) { + if (close_subtransport) { git__free(t->url); t->url = NULL; - } - if (close_subtransport && - t->wrapped->close(t->wrapped) < 0) - return -1; + if (t->wrapped->close(t->wrapped) < 0) + return -1; + } return 0; } |