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