aboutsummaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2009-11-03 21:38:51 -0500
committerJunio C Hamano <gitster@pobox.com>2009-11-03 21:39:28 -0800
commitc1d45cf7b0c1953eed72a3018b5e557dbcd538e0 (patch)
tree1840f9d24721f43b1a8c3b693b3c75410529d08b /transport.c
parentb26f39cd9739ea1b4149c7ff79469d953440c913 (diff)
downloadgit-c1d45cf7b0c1953eed72a3018b5e557dbcd538e0.tar.gz
git-c1d45cf7b0c1953eed72a3018b5e557dbcd538e0.tar.xz
Require a struct remote in transport_get()
cmd_ls_remote() was calling transport_get() with a NULL remote and a non-NULL url in the case where it was run outside a git repository. This involved a bunch of ill-tested special cases. Instead, simply get the struct remote for the URL with remote_get(), which works fine outside a git repository, and can also take global options into account. This fixes a tiny and obscure bug where "git ls-remote" without a repo didn't support global url.*.insteadOf, even though "git clone" and "git ls-remote" in any repo did. Also, enforce that all callers provide a struct remote to transport_get(). Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/transport.c b/transport.c
index 644a30a0b..298dc46ec 100644
--- a/transport.c
+++ b/transport.c
@@ -812,6 +812,9 @@ struct transport *transport_get(struct remote *remote, const char *url)
{
struct transport *ret = xcalloc(1, sizeof(*ret));
+ if (!remote)
+ die("No remote provided to transport_get()");
+
ret->remote = remote;
ret->url = url;
@@ -849,10 +852,10 @@ struct transport *transport_get(struct remote *remote, const char *url)
data->thin = 1;
data->conn = NULL;
data->uploadpack = "git-upload-pack";
- if (remote && remote->uploadpack)
+ if (remote->uploadpack)
data->uploadpack = remote->uploadpack;
data->receivepack = "git-receive-pack";
- if (remote && remote->receivepack)
+ if (remote->receivepack)
data->receivepack = remote->receivepack;
}