1#include "cache.h"
2#include "commit.h"
3#include "rsh.h"
4#include "pull.h"
5
6static int fd_in;
7static int fd_out;
8
9int fetch(unsigned char *sha1)
10{
11 int ret;
12 write(fd_out, sha1, 20);
13 ret = write_sha1_from_fd(sha1, fd_in);
14 if (!ret)
15 pull_say("got %s\n", sha1_to_hex(sha1));
16 return ret;
17}
18
19int main(int argc, char **argv)
20{
21 char *commit_id;
22 char *url;
23 int arg = 1;
24
25 while (arg < argc && argv[arg][0] == '-') {
26 if (argv[arg][1] == 't') {
27 get_tree = 1;
28 } else if (argv[arg][1] == 'c') {
29 get_history = 1;
30 } else if (argv[arg][1] == 'a') {
31 get_all = 1;
32 get_tree = 1;
33 get_history = 1;
34 } else if (argv[arg][1] == 'v') {
35 get_verbosely = 1;
36 }
37 arg++;
38 }
39 if (argc < arg + 2) {
40 usage("git-rpull [-c] [-t] [-a] [-v] commit-id url");
41 return 1;
42 }
43 commit_id = argv[arg];
44 url = argv[arg + 1];
45
46 if (setup_connection(&fd_in, &fd_out, "git-rpush", url, arg, argv + 1))
47 return 1;
48
49 if (pull(commit_id))
50 return 1;
51
52 return 0;
53}