rpull.con commit Fix missing '\n' at end of git-cat-file -t output. (fa9e9c7)
   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        if (has_sha1_file(sha1))
  18                return 0;
  19        write(fd_out, sha1, 20);
  20        return write_sha1_from_fd(sha1, fd_in);
  21}
  22
  23int main(int argc, char **argv)
  24{
  25        char *commit_id;
  26        char *url;
  27        int arg = 1;
  28
  29        while (arg < argc && argv[arg][0] == '-') {
  30                if (argv[arg][1] == 't') {
  31                        get_tree = 1;
  32                } else if (argv[arg][1] == 'c') {
  33                        get_history = 1;
  34                } else if (argv[arg][1] == 'a') {
  35                        get_all = 1;
  36                        get_tree = 1;
  37                        get_history = 1;
  38                }
  39                arg++;
  40        }
  41        if (argc < arg + 2) {
  42                usage("rpull [-c] [-t] [-a] 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, "rpush", url, arg, argv + 1))
  49                return 1;
  50
  51        if (pull(commit_id))
  52                return 1;
  53
  54        return 0;
  55}