rpull.con commit Teach "git-pull-script" about alternate HEAD's to pull.. (552e2bd)
   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"
  11
  12static int fd_in;
  13static int fd_out;
  14
  15int fetch(unsigned char *sha1)
  16{
  17        write(fd_out, sha1, 20);
  18        return write_sha1_from_fd(sha1, fd_in);
  19}
  20
  21int main(int argc, char **argv)
  22{
  23        char *commit_id;
  24        char *url;
  25        int arg = 1;
  26
  27        while (arg < argc && argv[arg][0] == '-') {
  28                if (argv[arg][1] == 't') {
  29                        get_tree = 1;
  30                } else if (argv[arg][1] == 'c') {
  31                        get_history = 1;
  32                } else if (argv[arg][1] == 'a') {
  33                        get_all = 1;
  34                        get_tree = 1;
  35                        get_history = 1;
  36                }
  37                arg++;
  38        }
  39        if (argc < arg + 2) {
  40                usage("rpull [-c] [-t] [-a] 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, "rpush", url, arg, argv + 1))
  47                return 1;
  48
  49        if (pull(commit_id))
  50                return 1;
  51
  52        return 0;
  53}