]>
git.proxmox.com Git - libgit2.git/blob - src/transport.c
2 * Copyright (C) 2009-2011 the libgit2 contributors
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
8 #include "git2/types.h"
9 #include "git2/transport.h"
11 #include "transport.h"
17 {"git://", git_transport_git
},
18 {"http://", git_transport_http
},
19 {"https://", git_transport_dummy
},
20 {"file://", git_transport_local
},
21 {"git+ssh://", git_transport_dummy
},
22 {"ssh+git://", git_transport_dummy
},
26 static git_transport_cb
transport_new_fn(const char *url
)
31 if (transports
[i
].prefix
== NULL
)
34 if (!strncasecmp(url
, transports
[i
].prefix
, strlen(transports
[i
].prefix
)))
35 return transports
[i
].fn
;
41 * If we still haven't found the transport, we assume we mean a
43 * TODO: Parse "example.com:project.git" as an SSH URL
45 return git_transport_local
;
52 int git_transport_dummy(git_transport
**GIT_UNUSED(transport
))
54 GIT_UNUSED_ARG(transport
);
55 return git__throw(GIT_ENOTIMPLEMENTED
, "This protocol isn't implemented. Sorry");
58 int git_transport_new(git_transport
**out
, const char *url
)
61 git_transport
*transport
;
64 fn
= transport_new_fn(url
);
66 error
= fn(&transport
);
67 if (error
< GIT_SUCCESS
)
68 return git__rethrow(error
, "Failed to create new transport");
70 transport
->url
= git__strdup(url
);
71 if (transport
->url
== NULL
)