X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=connect.c;h=a6657b13848b5474ffde7edb0ad60ed969f22852;hb=3e386508f87278610d1892aaaa08cd17907f71c5;hp=3953a1af3d321091d53a1381ded0be1abb4d9deb;hpb=4fa1604f10c4878ae2cfbe4b9419a67d6306bb5d;p=git.git diff --git a/connect.c b/connect.c index 3953a1af..a6657b13 100644 --- a/connect.c +++ b/connect.c @@ -133,6 +133,20 @@ static void link_dst_tail(struct ref *ref, struct ref ***tail) **tail = NULL; } +static struct ref *try_explicit_object_name(const char *name) +{ + unsigned char sha1[20]; + struct ref *ref; + int len; + if (get_sha1(name, sha1)) + return NULL; + len = strlen(name) + 1; + ref = xcalloc(1, sizeof(*ref) + len); + memcpy(ref->name, name, len); + memcpy(ref->new_sha1, sha1, 20); + return ref; +} + static int match_explicit_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail, struct refspec *rs) { @@ -145,8 +159,15 @@ static int match_explicit_refs(struct ref *src, struct ref *dst, case 1: break; case 0: + /* The source could be in the get_sha1() format + * not a reference name. + */ + matched_src = try_explicit_object_name(rs[i].src); + if (matched_src) + break; errs = 1; - error("src refspec %s does not match any."); + error("src refspec %s does not match any.", + rs[i].src); break; default: errs = 1; @@ -190,13 +211,6 @@ static int match_explicit_refs(struct ref *src, struct ref *dst, } if (errs) continue; - if (matched_src->peer_ref) { - errs = 1; - error("src ref %s is sent to more than one dst.", - matched_src->name); - } - else - matched_src->peer_ref = matched_dst; if (matched_dst->peer_ref) { errs = 1; error("dst ref %s receives from more than one src.", @@ -368,8 +382,15 @@ int git_connect(int fd[2], char *url, const char *prog) close(pipefd[0][1]); close(pipefd[1][0]); close(pipefd[1][1]); - if (protocol == PROTO_SSH) - execlp("ssh", "ssh", host, command, NULL); + if (protocol == PROTO_SSH) { + const char *ssh = getenv("GIT_SSH") ? : "ssh"; + const char *ssh_basename = strrchr(ssh, '/'); + if (!ssh_basename) + ssh_basename = ssh; + else + ssh_basename++; + execlp(ssh, ssh_basename, host, command, NULL); + } else execlp("sh", "sh", "-c", command, NULL); die("exec failed");