X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=connect.c;h=075683e83c48282dfbd2626e89047af398cc7e4d;hb=41cb7488b9e5998ce1d665bbe10beca0a0f69c1c;hp=60b87f5867eaed8240d943b83dd7a5032ed5f89b;hpb=f71925983ddc365c167559ecc623f2c000607cda;p=git.git diff --git a/connect.c b/connect.c index 60b87f58..075683e8 100644 --- a/connect.c +++ b/connect.c @@ -1,6 +1,46 @@ #include "cache.h" +#include "pkt-line.h" #include +int get_ack(int fd, unsigned char *result_sha1) +{ + static char line[1000]; + int len = packet_read_line(fd, line, sizeof(line)); + + if (!len) + die("git-fetch-pack: expected ACK/NAK, got EOF"); + if (line[len-1] == '\n') + line[--len] = 0; + if (!strcmp(line, "NAK")) + return 0; + if (!strncmp(line, "ACK ", 3)) { + if (!get_sha1_hex(line+4, result_sha1)) + return 1; + } + die("git-fetch_pack: expected ACK/NAK, got '%s'", line); +} + +int path_match(const char *path, int nr, char **match) +{ + int i; + int pathlen = strlen(path); + + for (i = 0; i < nr; i++) { + char *s = match[i]; + int len = strlen(s); + + if (!len || len > pathlen) + continue; + if (memcmp(path + pathlen - len, s, len)) + continue; + if (pathlen > len && path[pathlen - len - 1] != '/') + continue; + *s = 0; + return 1; + } + return 0; +} + /* * First, make it shell-safe. We do this by just disallowing any * special characters. Somebody who cares can do escaping and let