Clarify dual license status of subprocess.py file.
[git/gitweb.git] / peek-remote.c
blob4b1d0d5ba8ebb61c50a8766c73c6ba19e6efdef9
1 #include "cache.h"
2 #include "refs.h"
3 #include "pkt-line.h"
4 #include <sys/wait.h>
6 static const char peek_remote_usage[] =
7 "git-peek-remote [--exec=upload-pack] [host:]directory";
8 static const char *exec = "git-upload-pack";
10 static int peek_remote(int fd[2])
12 struct ref *ref;
14 get_remote_heads(fd[0], &ref, 0, NULL);
15 packet_flush(fd[1]);
17 while (ref) {
18 printf("%s %s\n", sha1_to_hex(ref->old_sha1), ref->name);
19 ref = ref->next;
21 return 0;
24 int main(int argc, char **argv)
26 int i, ret;
27 char *dest = NULL;
28 int fd[2];
29 pid_t pid;
31 for (i = 1; i < argc; i++) {
32 char *arg = argv[i];
34 if (*arg == '-') {
35 if (!strncmp("--exec=", arg, 7))
36 exec = arg + 7;
37 else
38 usage(peek_remote_usage);
39 continue;
41 dest = arg;
42 break;
44 if (!dest || i != argc - 1)
45 usage(peek_remote_usage);
47 pid = git_connect(fd, dest, exec);
48 if (pid < 0)
49 return 1;
50 ret = peek_remote(fd);
51 close(fd[0]);
52 close(fd[1]);
53 finish_connect(pid);
54 return ret;