summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 638794c)
raw | patch | inline | side by side (parent: 638794c)
author | Jeff King <peff@peff.net> | |
Sun, 23 May 2010 09:19:44 +0000 (05:19 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 24 May 2010 23:48:34 +0000 (16:48 -0700) |
We generally treat these as equivalent to "/path/to/repo"
and "host:path_to_repo" respectively. However, they are URLs
and as such may be percent-encoded. The current code simply
uses them as-is without any decoding.
With this patch, we will now percent-decode any file:// or
ssh:// url (or ssh+git, git+ssh, etc) at the transport
layer. We continue to treat plain paths and "host:path"
syntax literally.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
and "host:path_to_repo" respectively. However, they are URLs
and as such may be percent-encoded. The current code simply
uses them as-is without any decoding.
With this patch, we will now percent-decode any file:// or
ssh:// url (or ssh+git, git+ssh, etc) at the transport
layer. We continue to treat plain paths and "host:path"
syntax literally.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
connect.c | patch | blob | history | |
t/t5601-clone.sh | patch | blob | history |
diff --git a/connect.c b/connect.c
index 9ae991ac42544716599ff8bf3ebaaa376c8119e4..0119bd377b23388c0c9ea41ee9fd134034c5a443 100644 (file)
--- a/connect.c
+++ b/connect.c
#include "refs.h"
#include "run-command.h"
#include "remote.h"
+#include "url.h"
static char *server_capabilities;
struct child_process *git_connect(int fd[2], const char *url_orig,
const char *prog, int flags)
{
- char *url = xstrdup(url_orig);
+ char *url;
char *host, *path;
char *end;
int c;
*/
signal(SIGCHLD, SIG_DFL);
+ if (is_url(url_orig))
+ url = url_decode(url_orig);
+ else
+ url = xstrdup(url_orig);
+
host = strstr(url, "://");
if (host) {
*host = '\0';
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 678cee502de54e5a9c18a43f114446d3392ec7f3..8abb71afcd4d7389260baa6f82ecb9b53bb9524c 100755 (executable)
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
)
'
+test_expect_success 'respect url-encoding of file://' '
+ git init x+y &&
+ test_must_fail git clone "file://$PWD/x+y" xy-url &&
+ git clone "file://$PWD/x%2By" xy-url
+'
+
+test_expect_success 'do not respect url-encoding of non-url path' '
+ git init x+y &&
+ test_must_fail git clone x%2By xy-regular &&
+ git clone x+y xy-regular
+'
+
test_done