#define COMMAND_SIZE 4096
-int setup_connection(int *fd_in, int *fd_out, char *remote_prog,
+int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
char *url, int rmt_argc, char **rmt_argv)
{
char *host;
}
host = strstr(url, "//");
- if (!host) {
- return error("Bad URL: %s", url);
+ if (host) {
+ host += 2;
+ path = strchr(host, '/');
+ } else {
+ host = url;
+ path = strchr(host, ':');
}
- host += 2;
- path = strchr(host, '/');
if (!path) {
return error("Bad URL: %s", url);
}
#ifndef RSH_H
#define RSH_H
-int setup_connection(int *fd_in, int *fd_out, char *remote_prog,
+int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
char *url, int rmt_argc, char **rmt_argv);
#endif
char *commit_id;
char *url;
int arg = 1;
+ const char *prog = getenv("GIT_SSH_PUSH") ? : "git-ssh-push";
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
commit_id = argv[arg];
url = argv[arg + 1];
- if (setup_connection(&fd_in, &fd_out, "git-ssh-push", url, arg, argv + 1))
+ if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
return 1;
if (get_version())
char *commit_id;
char *url;
int fd_in, fd_out;
+ const char *prog = getenv("GIT_SSH_PULL") ? : "git-ssh-pull";
+
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 'w')
arg++;
}
commit_id = argv[arg];
url = argv[arg + 1];
- if (setup_connection(&fd_in, &fd_out, "git-ssh-pull", url, arg, argv + 1))
+ if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
return 1;
service(fd_in, fd_out);