3 #include <sys/socket.h>
6 static void service(int fd_in, int fd_out) {
9 char unsigned sha1[20];
10 unsigned long objsize;
15 size = read(fd_in, sha1 + posn, 20 - posn);
17 perror("git-rpush: read ");
25 /* fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1)); */
27 buf = map_sha1_file(sha1, &objsize);
29 fprintf(stderr, "git-rpush: could not find %s\n",
35 size = write(fd_out, buf + posn, objsize - posn);
38 fprintf(stderr, "git-rpush: write closed");
40 perror("git-rpush: write ");
45 } while (posn < objsize);
49 int main(int argc, char **argv)
55 while (arg < argc && argv[arg][0] == '-') {
59 usage("git-rpush [-c] [-t] [-a] commit-id url");
62 commit_id = argv[arg];
64 if (setup_connection(&fd_in, &fd_out, "git-rpull", url, arg, argv + 1))
67 service(fd_in, fd_out);