Skip to content

Commit 72a4f4b

Browse files
torvaldsgitster
authored andcommitted
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>
1 parent 50cff52 commit 72a4f4b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

connect.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ static enum protocol get_protocol(const char *name)
145145
return PROTO_SSH;
146146
if (!strcmp(name, "ssh+git"))
147147
return PROTO_SSH;
148+
if (!strcmp(name, "file"))
149+
return PROTO_LOCAL;
148150
die("I don't handle protocol '%s'", name);
149151
}
150152

@@ -498,13 +500,13 @@ pid_t git_connect(int fd[2], char *url, const char *prog, int flags)
498500
end = host;
499501

500502
path = strchr(end, c);
501-
if (c == ':') {
502-
if (path) {
503+
if (path) {
504+
if (c == ':') {
503505
protocol = PROTO_SSH;
504506
*path++ = '\0';
505-
} else
506-
path = host;
507-
}
507+
}
508+
} else
509+
path = end;
508510

509511
if (!path || !*path)
510512
die("No path specified. See 'man git-pull' for valid url syntax");

0 commit comments

Comments
 (0)