10 static unsigned char remote_version
= 0;
11 static unsigned char local_version
= 1;
13 void prefetch(unsigned char *sha1
)
17 int fetch(unsigned char *sha1
)
22 if (has_sha1_file(sha1
))
24 write(fd_out
, &type
, 1);
25 write(fd_out
, sha1
, 20);
26 if (read(fd_in
, &remote
, 1) < 1)
30 ret
= write_sha1_from_fd(sha1
, fd_in
);
32 pull_say("got %s\n", sha1_to_hex(sha1
));
36 static int get_version(void)
39 write(fd_out
, &type
, 1);
40 write(fd_out
, &local_version
, 1);
41 if (read(fd_in
, &remote_version
, 1) < 1) {
42 return error("Couldn't read version from remote end");
47 int fetch_ref(char *ref
, unsigned char *sha1
)
51 write(fd_out
, &type
, 1);
52 write(fd_out
, ref
, strlen(ref
) + 1);
53 read(fd_in
, &remote
, 1);
56 read(fd_in
, sha1
, 20);
60 int main(int argc
, char **argv
)
65 const char *prog
= getenv("GIT_SSH_PUSH") ? : "git-ssh-push";
67 while (arg
< argc
&& argv
[arg
][0] == '-') {
68 if (argv
[arg
][1] == 't') {
70 } else if (argv
[arg
][1] == 'c') {
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))