fsck-cache: walk the 'refs' directory if the user doesn't give any
[git/kirr.git] / rpull.c
blobb48e63157c66c160b9751603a92831f77106044c
1 #include <fcntl.h>
2 #include <unistd.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #include "cache.h"
6 #include "commit.h"
7 #include <errno.h>
8 #include <stdio.h>
9 #include "rsh.h"
10 #include "pull.h"
12 static int fd_in;
13 static int fd_out;
15 int fetch(unsigned char *sha1)
17 int ret;
18 write(fd_out, sha1, 20);
19 ret = write_sha1_from_fd(sha1, fd_in);
20 if (!ret)
21 pull_say("got %s\n", sha1_to_hex(sha1));
22 return ret;
25 int main(int argc, char **argv)
27 char *commit_id;
28 char *url;
29 int arg = 1;
31 while (arg < argc && argv[arg][0] == '-') {
32 if (argv[arg][1] == 't') {
33 get_tree = 1;
34 } else if (argv[arg][1] == 'c') {
35 get_history = 1;
36 } else if (argv[arg][1] == 'a') {
37 get_all = 1;
38 get_tree = 1;
39 get_history = 1;
40 } else if (argv[arg][1] == 'v') {
41 get_verbosely = 1;
43 arg++;
45 if (argc < arg + 2) {
46 usage("git-rpull [-c] [-t] [-a] [-v] commit-id url");
47 return 1;
49 commit_id = argv[arg];
50 url = argv[arg + 1];
52 if (setup_connection(&fd_in, &fd_out, "git-rpush", url, arg, argv + 1))
53 return 1;
55 if (pull(commit_id))
56 return 1;
58 return 0;