[PATCH] git-tar-tree: cleanup write_trailer()
[git.git] / rpull.c
1 #include "cache.h"
2 #include "commit.h"
3 #include "rsh.h"
4 #include "pull.h"
5
6 static int fd_in;
7 static int fd_out;
8
9 int 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
19 int 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] == 'd') {
31                         get_delta = 0;
32                 } else if (argv[arg][1] == 'a') {
33                         get_all = 1;
34                         get_tree = 1;
35                         get_history = 1;
36                 } else if (argv[arg][1] == 'v') {
37                         get_verbosely = 1;
38                 }
39                 arg++;
40         }
41         if (argc < arg + 2) {
42                 usage("git-rpull [-c] [-t] [-a] [-v] [-d] commit-id url");
43                 return 1;
44         }
45         commit_id = argv[arg];
46         url = argv[arg + 1];
47
48         if (setup_connection(&fd_in, &fd_out, "git-rpush", url, arg, argv + 1))
49                 return 1;
50
51         if (pull(commit_id))
52                 return 1;
53
54         return 0;
55 }