summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorTorsten Bögershausen <tboegi@web.de>2013-11-28 19:50:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-12-09 22:54:48 (GMT)
commitc59ab2e52a64abd7fded97e0983a9b7f3d0508a0 (patch)
treeec8fbc7ea0cc3a49ee0519425c486d03bb1325cc /transport.c
parent83b058752707a6ba4af51ebc98c47913bc7d2d25 (diff)
downloadgit-c59ab2e52a64abd7fded97e0983a9b7f3d0508a0.zip
git-c59ab2e52a64abd7fded97e0983a9b7f3d0508a0.tar.gz
git-c59ab2e52a64abd7fded97e0983a9b7f3d0508a0.tar.bz2
connect.c: refactor url parsing
Make the function is_local() in transport.c public, rename it into url_is_local_not_ssh() and use it in both transport.c and connect.c Use a protocol "local" for URLs for the local file system. One note about using file:// under Windows: The (absolute) path on Unix like system typically starts with "/". When the host is empty, it can be omitted, so that a shell scriptlet url=file://$pwd will give a URL like "file:///home/user/repo". Windows does not have the same concept of a root directory located in "/". When parsing the URL allow "file://C:/user/repo" (even if RFC1738 indicates that "file:///C:/user/repo" should be used). Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/transport.c b/transport.c
index 7202b77..5485e2a 100644
--- a/transport.c
+++ b/transport.c
@@ -885,14 +885,6 @@ void transport_take_over(struct transport *transport,
transport->cannot_reuse = 1;
}
-static int is_local(const char *url)
-{
- const char *colon = strchr(url, ':');
- const char *slash = strchr(url, '/');
- return !colon || (slash && slash < colon) ||
- has_dos_drive_prefix(url);
-}
-
static int is_file(const char *url)
{
struct stat buf;
@@ -941,7 +933,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
ret->fetch = fetch_objs_via_rsync;
ret->push = rsync_transport_push;
ret->smart_options = NULL;
- } else if (is_local(url) && is_file(url) && is_bundle(url, 1)) {
+ } else if (url_is_local_not_ssh(url) && is_file(url) && is_bundle(url, 1)) {
struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
ret->data = data;
ret->get_refs_list = get_refs_from_bundle;
@@ -1297,7 +1289,7 @@ char *transport_anonymize_url(const char *url)
size_t anon_len, prefix_len = 0;
anon_part = strchr(url, '@');
- if (is_local(url) || !anon_part)
+ if (url_is_local_not_ssh(url) || !anon_part)
goto literal_copy;
anon_len = strlen(++anon_part);