10 static unsigned char remote_version = 0;
11 static unsigned char local_version = 1;
13 int fetch(unsigned char *sha1)
18 if (has_sha1_file(sha1))
20 write(fd_out, &type, 1);
21 write(fd_out, sha1, 20);
22 if (read(fd_in, &remote, 1) < 1)
26 ret = write_sha1_from_fd(sha1, fd_in);
28 pull_say("got %s\n", sha1_to_hex(sha1));
35 write(fd_out, &type, 1);
36 write(fd_out, &local_version, 1);
37 if (read(fd_in, &remote_version, 1) < 1) {
38 return error("Couldn't read version from remote end");
43 int fetch_ref(char *ref, unsigned char *sha1)
47 write(fd_out, &type, 1);
48 write(fd_out, ref, strlen(ref) + 1);
49 read(fd_in, &remote, 1);
52 read(fd_in, sha1, 20);
56 int main(int argc, char **argv)
61 const char *prog = getenv("GIT_SSH_PUSH") ? : "git-ssh-push";
63 while (arg < argc && argv[arg][0] == '-') {
64 if (argv[arg][1] == 't') {
66 } else if (argv[arg][1] == 'c') {
68 } else if (argv[arg][1] == 'd') {
70 } else if (!strcmp(argv[arg], "--recover")) {
72 } else if (argv[arg][1] == 'a') {
76 } else if (argv[arg][1] == 'v') {
78 } else if (argv[arg][1] == 'w') {
79 write_ref = argv[arg + 1];
85 usage("git-ssh-pull [-c] [-t] [-a] [-v] [-d] [--recover] [-w ref] commit-id url");
88 commit_id = argv[arg];
91 if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))