connect: accept file:// URL scheme
We might make it something like: "if you use an url, we don't default to local", so the difference would be that git clone file:///directory/to/repo would work the way it does now, but git clone /directory/to/repo would default to "-l" behaviour. That kind of would make sense (and should be easy to implement. This adds support for "file://" URL to underlying connect codepath to make it happen. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Linus Torvalds committed
Aug 1, 2007 at 10:03 UTC
72a4f4b657846af6c65360d92aa09d8b7f3dfbb0
1 file changed
+7
-5
connect.c
+7
-5
@@ -145,6 +145,8 @@ static enum protocol get_protocol(const char *name)
145
return PROTO_SSH;
146
if (!strcmp(name, "ssh+git"))
147
return PROTO_SSH;
148
+ if (!strcmp(name, "file"))
149
+ return PROTO_LOCAL;
150
die("I don't handle protocol '%s'", name);
151
}
152
@@ -498,13 +500,13 @@ pid_t git_connect(int fd[2], char *url, const char *prog, int flags)
500
end = host;
501
502
path = strchr(end, c);
501
- if (c == ':') {
502
- if (path) {
503
+ if (path) {
504
+ if (c == ':') {
505
protocol = PROTO_SSH;
506
*path++ = '\0';
505
- } else
506
- path = host;
507
- }
507
+ }
508
+ } else
509
+ path = end;
510
511
if (!path || !*path)
512
die("No path specified. See 'man git-pull' for valid url syntax");