Remove obsolete commit-walkers
Removes the commit-walkers that are no longer useful, as well as library code that was only used by ssh-fetch/push. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Daniel Barkalow committed
Sep 10, 2007 at 23:02 UTC
fbdeef948bbc085124f9634d5108940dce5fc688
8 files changed
+4
-677
Makefile
+4
-16
@@ -234,14 +234,14 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
234
# ... and all the rest that could be moved out of bindir to gitexecdir
235
PROGRAMS = \
236
git-convert-objects$X git-fetch-pack$X \
237
- git-hash-object$X git-index-pack$X git-local-fetch$X \
237
+ git-hash-object$X git-index-pack$X \
238
git-fast-import$X \
239
git-daemon$X \
240
git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
241
git-peek-remote$X git-receive-pack$X \
242
git-send-pack$X git-shell$X \
243
- git-show-index$X git-ssh-fetch$X \
244
- git-ssh-upload$X git-unpack-file$X \
243
+ git-show-index$X \
244
+ git-unpack-file$X \
245
git-update-server-info$X \
246
git-upload-pack$X \
247
git-pack-redundant$X git-var$X \
@@ -269,9 +269,6 @@ ifndef NO_TCLTK
269
OTHER_PROGRAMS += gitk-wish
270
endif
271
272
-# Backward compatibility -- to be removed after 1.0
273
-PROGRAMS += git-ssh-pull$X git-ssh-push$X
274
-
272
# Set paths to tools early so that they can be used for version tests.
273
ifndef SHELL_PATH
274
SHELL_PATH = /bin/sh
@@ -894,14 +891,6 @@ endif
891
git-%$X: %.o $(GITLIBS)
892
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
893
897
-ssh-pull.o: ssh-fetch.c
898
-ssh-push.o: ssh-upload.c
899
-git-local-fetch$X: fetch.o
900
-git-ssh-fetch$X: rsh.o fetch.o
901
-git-ssh-upload$X: rsh.o
902
-git-ssh-pull$X: rsh.o fetch.o
903
-git-ssh-push$X: rsh.o
904
-
894
git-imap-send$X: imap-send.o $(LIB_FILE)
895
896
http.o http-fetch.o http-push.o: http.h
@@ -1122,8 +1111,7 @@ check-docs::
1111
git-merge-octopus | git-merge-ours | git-merge-recursive | \
1112
git-merge-resolve | git-merge-stupid | \
1113
git-add--interactive | git-fsck-objects | git-init-db | \
1125
- git-repo-config | git-fetch--tool | \
1126
- git-ssh-pull | git-ssh-push ) continue ;; \
1114
+ git-repo-config | git-fetch--tool ) continue ;; \
1115
esac ; \
1116
test -f "Documentation/$$v.txt" || \
1117
echo "no doc: $$v"; \
local-fetch.c
deleted
-254
@@ -1,254 +0,0 @@
1
-/*
2
- * Copyright (C) 2005 Junio C Hamano
3
- */
4
-#include "cache.h"
5
-#include "commit.h"
6
-#include "fetch.h"
7
-
8
-static int use_link;
9
-static int use_symlink;
10
-static int use_filecopy = 1;
11
-static int commits_on_stdin;
12
-
13
-static const char *path; /* "Remote" git repository */
14
-
15
-void prefetch(unsigned char *sha1)
16
-{
17
-}
18
-
19
-static struct packed_git *packs;
20
-
21
-static void setup_index(unsigned char *sha1)
22
-{
23
- struct packed_git *new_pack;
24
- char filename[PATH_MAX];
25
- strcpy(filename, path);
26
- strcat(filename, "/objects/pack/pack-");
27
- strcat(filename, sha1_to_hex(sha1));
28
- strcat(filename, ".idx");
29
- new_pack = parse_pack_index_file(sha1, filename);
30
- new_pack->next = packs;
31
- packs = new_pack;
32
-}
33
-
34
-static int setup_indices(void)
35
-{
36
- DIR *dir;
37
- struct dirent *de;
38
- char filename[PATH_MAX];
39
- unsigned char sha1[20];
40
- sprintf(filename, "%s/objects/pack/", path);
41
- dir = opendir(filename);
42
- if (!dir)
43
- return -1;
44
- while ((de = readdir(dir)) != NULL) {
45
- int namelen = strlen(de->d_name);
46
- if (namelen != 50 ||
47
- !has_extension(de->d_name, ".pack"))
48
- continue;
49
- get_sha1_hex(de->d_name + 5, sha1);
50
- setup_index(sha1);
51
- }
52
- closedir(dir);
53
- return 0;
54
-}
55
-
56
-static int copy_file(const char *source, char *dest, const char *hex,
57
- int warn_if_not_exists)
58
-{
59
- safe_create_leading_directories(dest);
60
- if (use_link) {
61
- if (!link(source, dest)) {
62
- pull_say("link %s\n", hex);
63
- return 0;
64
- }
65
- /* If we got ENOENT there is no point continuing. */
66
- if (errno == ENOENT) {
67
- if (!warn_if_not_exists)
68
- return -1;
69
- return error("does not exist %s", source);
70
- }
71
- }
72
- if (use_symlink) {
73
- struct stat st;
74
- if (stat(source, &st)) {
75
- if (!warn_if_not_exists && errno == ENOENT)
76
- return -1;
77
- return error("cannot stat %s: %s", source,
78
- strerror(errno));
79
- }
80
- if (!symlink(source, dest)) {
81
- pull_say("symlink %s\n", hex);
82
- return 0;
83
- }
84
- }
85
- if (use_filecopy) {
86
- int ifd, ofd, status = 0;
87
-
88
- ifd = open(source, O_RDONLY);
89
- if (ifd < 0) {
90
- if (!warn_if_not_exists && errno == ENOENT)
91
- return -1;
92
- return error("cannot open %s", source);
93
- }
94
- ofd = open(dest, O_WRONLY | O_CREAT | O_EXCL, 0666);
95
- if (ofd < 0) {
96
- close(ifd);
97
- return error("cannot open %s", dest);
98
- }
99
- status = copy_fd(ifd, ofd);
100
- close(ofd);
101
- if (status)
102
- return error("cannot write %s", dest);
103
- pull_say("copy %s\n", hex);
104
- return 0;
105
- }
106
- return error("failed to copy %s with given copy methods.", hex);
107
-}
108
-
109
-static int fetch_pack(const unsigned char *sha1)
110
-{
111
- struct packed_git *target;
112
- char filename[PATH_MAX];
113
- if (setup_indices())
114
- return -1;
115
- target = find_sha1_pack(sha1, packs);
116
- if (!target)
117
- return error("Couldn't find %s: not separate or in any pack",
118
- sha1_to_hex(sha1));
119
- if (get_verbosely) {
120
- fprintf(stderr, "Getting pack %s\n",
121
- sha1_to_hex(target->sha1));
122
- fprintf(stderr, " which contains %s\n",
123
- sha1_to_hex(sha1));
124
- }
125
- sprintf(filename, "%s/objects/pack/pack-%s.pack",
126
- path, sha1_to_hex(target->sha1));
127
- copy_file(filename, sha1_pack_name(target->sha1),
128
- sha1_to_hex(target->sha1), 1);
129
- sprintf(filename, "%s/objects/pack/pack-%s.idx",
130
- path, sha1_to_hex(target->sha1));
131
- copy_file(filename, sha1_pack_index_name(target->sha1),
132
- sha1_to_hex(target->sha1), 1);
133
- install_packed_git(target);
134
- return 0;
135
-}
136
-
137
-static int fetch_file(const unsigned char *sha1)
138
-{
139
- static int object_name_start = -1;
140
- static char filename[PATH_MAX];
141
- char *hex = sha1_to_hex(sha1);
142
- char *dest_filename = sha1_file_name(sha1);
143
-
144
- if (object_name_start < 0) {
145
- strcpy(filename, path); /* e.g. git.git */
146
- strcat(filename, "/objects/");
147
- object_name_start = strlen(filename);
148
- }
149
- filename[object_name_start+0] = hex[0];
150
- filename[object_name_start+1] = hex[1];
151
- filename[object_name_start+2] = '/';
152
- strcpy(filename + object_name_start + 3, hex + 2);
153
- return copy_file(filename, dest_filename, hex, 0);
154
-}
155
-
156
-int fetch(unsigned char *sha1)
157
-{
158
- if (has_sha1_file(sha1))
159
- return 0;
160
- else
161
- return fetch_file(sha1) && fetch_pack(sha1);
162
-}
163
-
164
-int fetch_ref(char *ref, unsigned char *sha1)
165
-{
166
- static int ref_name_start = -1;
167
- static char filename[PATH_MAX];
168
- static char hex[41];
169
- int ifd;
170
-
171
- if (ref_name_start < 0) {
172
- sprintf(filename, "%s/refs/", path);
173
- ref_name_start = strlen(filename);
174
- }
175
- strcpy(filename + ref_name_start, ref);
176
- ifd = open(filename, O_RDONLY);
177
- if (ifd < 0) {
178
- close(ifd);
179
- return error("cannot open %s", filename);
180
- }
181
- if (read_in_full(ifd, hex, 40) != 40 || get_sha1_hex(hex, sha1)) {
182
- close(ifd);
183
- return error("cannot read from %s", filename);
184
- }
185
- close(ifd);
186
- pull_say("ref %s\n", sha1_to_hex(sha1));
187
- return 0;
188
-}
189
-
190
-static const char local_pull_usage[] =
191
-"git-local-fetch [-c] [-t] [-a] [-v] [-w filename] [--recover] [-l] [-s] [-n] [--stdin] commit-id path";
192
-
193
-/*
194
- * By default we only use file copy.
195
- * If -l is specified, a hard link is attempted.
196
- * If -s is specified, then a symlink is attempted.
197
- * If -n is _not_ specified, then a regular file-to-file copy is done.
198
- */
199
-int main(int argc, const char **argv)
200
-{
201
- int commits;
202
- const char **write_ref = NULL;
203
- char **commit_id;
204
- int arg = 1;
205
-
206
- setup_git_directory();
207
- git_config(git_default_config);
208
-
209
- while (arg < argc && argv[arg][0] == '-') {
210
- if (argv[arg][1] == 't')
211
- get_tree = 1;
212
- else if (argv[arg][1] == 'c')
213
- get_history = 1;
214
- else if (argv[arg][1] == 'a') {
215
- get_all = 1;
216
- get_tree = 1;
217
- get_history = 1;
218
- }
219
- else if (argv[arg][1] == 'l')
220
- use_link = 1;
221
- else if (argv[arg][1] == 's')
222
- use_symlink = 1;
223
- else if (argv[arg][1] == 'n')
224
- use_filecopy = 0;
225
- else if (argv[arg][1] == 'v')
226
- get_verbosely = 1;
227
- else if (argv[arg][1] == 'w')
228
- write_ref = &argv[++arg];
229
- else if (!strcmp(argv[arg], "--recover"))
230
- get_recover = 1;
231
- else if (!strcmp(argv[arg], "--stdin"))
232
- commits_on_stdin = 1;
233
- else
234
- usage(local_pull_usage);
235
- arg++;
236
- }
237
- if (argc < arg + 2 - commits_on_stdin)
238
- usage(local_pull_usage);
239
- if (commits_on_stdin) {
240
- commits = pull_targets_stdin(&commit_id, &write_ref);
241
- } else {
242
- commit_id = (char **) &argv[arg++];
243
- commits = 1;
244
- }
245
- path = argv[arg];
246
-
247
- if (pull(commits, commit_id, write_ref, path))
248
- return 1;
249
-
250
- if (commits_on_stdin)
251
- pull_targets_free(commits, commit_id, write_ref);
252
-
253
- return 0;
254
-}
rsh.c
deleted
-83
@@ -1,83 +0,0 @@
1
-#include "cache.h"
2
-#include "rsh.h"
3
-#include "quote.h"
4
-
5
-#define COMMAND_SIZE 4096
6
-
7
-int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
8
- char *url, int rmt_argc, char **rmt_argv)
9
-{
10
- char *host;
11
- char *path;
12
- int sv[2];
13
- char command[COMMAND_SIZE];
14
- char *posn;
15
- int sizen;
16
- int of;
17
- int i;
18
- pid_t pid;
19
-
20
- if (!strcmp(url, "-")) {
21
- *fd_in = 0;
22
- *fd_out = 1;
23
- return 0;
24
- }
25
-
26
- host = strstr(url, "//");
27
- if (host) {
28
- host += 2;
29
- path = strchr(host, '/');
30
- } else {
31
- host = url;
32
- path = strchr(host, ':');
33
- if (path)
34
- *(path++) = '\0';
35
- }
36
- if (!path) {
37
- return error("Bad URL: %s", url);
38
- }
39
- /* $GIT_RSH <host> "env GIT_DIR=<path> <remote_prog> <args...>" */
40
- sizen = COMMAND_SIZE;
41
- posn = command;
42
- of = 0;
43
- of |= add_to_string(&posn, &sizen, "env ", 0);
44
- of |= add_to_string(&posn, &sizen, GIT_DIR_ENVIRONMENT "=", 0);
45
- of |= add_to_string(&posn, &sizen, path, 1);
46
- of |= add_to_string(&posn, &sizen, " ", 0);
47
- of |= add_to_string(&posn, &sizen, remote_prog, 1);
48
-
49
- for ( i = 0 ; i < rmt_argc ; i++ ) {
50
- of |= add_to_string(&posn, &sizen, " ", 0);
51
- of |= add_to_string(&posn, &sizen, rmt_argv[i], 1);
52
- }
53
-
54
- of |= add_to_string(&posn, &sizen, " -", 0);
55
-
56
- if ( of )
57
- return error("Command line too long");
58
-
59
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv))
60
- return error("Couldn't create socket");
61
-
62
- pid = fork();
63
- if (pid < 0)
64
- return error("Couldn't fork");
65
- if (!pid) {
66
- const char *ssh, *ssh_basename;
67
- ssh = getenv("GIT_SSH");
68
- if (!ssh) ssh = "ssh";
69
- ssh_basename = strrchr(ssh, '/');
70
- if (!ssh_basename)
71
- ssh_basename = ssh;
72
- else
73
- ssh_basename++;
74
- close(sv[1]);
75
- dup2(sv[0], 0);
76
- dup2(sv[0], 1);
77
- execlp(ssh, ssh_basename, host, command, NULL);
78
- }
79
- close(sv[0]);
80
- *fd_in = sv[1];
81
- *fd_out = sv[1];
82
- return 0;
83
-}
rsh.h
deleted
-7
@@ -1,7 +0,0 @@
1
-#ifndef RSH_H
2
-#define RSH_H
3
-
4
-int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
5
- char *url, int rmt_argc, char **rmt_argv);
6
-
7
-#endif
ssh-fetch.c
deleted
-166
@@ -1,166 +0,0 @@
1
-#ifndef COUNTERPART_ENV_NAME
2
-#define COUNTERPART_ENV_NAME "GIT_SSH_UPLOAD"
3
-#endif
4
-#ifndef COUNTERPART_PROGRAM_NAME
5
-#define COUNTERPART_PROGRAM_NAME "git-ssh-upload"
6
-#endif
7
-#ifndef MY_PROGRAM_NAME
8
-#define MY_PROGRAM_NAME "git-ssh-fetch"
9
-#endif
10
-
11
-#include "cache.h"
12
-#include "commit.h"
13
-#include "rsh.h"
14
-#include "fetch.h"
15
-#include "refs.h"
16
-
17
-static int fd_in;
18
-static int fd_out;
19
-
20
-static unsigned char remote_version;
21
-static unsigned char local_version = 1;
22
-
23
-static int prefetches;
24
-
25
-static struct object_list *in_transit;
26
-static struct object_list **end_of_transit = &in_transit;
27
-
28
-void prefetch(unsigned char *sha1)
29
-{
30
- char type = 'o';
31
- struct object_list *node;
32
- if (prefetches > 100) {
33
- fetch(in_transit->item->sha1);
34
- }
35
- node = xmalloc(sizeof(struct object_list));
36
- node->next = NULL;
37
- node->item = lookup_unknown_object(sha1);
38
- *end_of_transit = node;
39
- end_of_transit = &node->next;
40
- /* XXX: what if these writes fail? */
41
- write_in_full(fd_out, &type, 1);
42
- write_in_full(fd_out, sha1, 20);
43
- prefetches++;
44
-}
45
-
46
-static char conn_buf[4096];
47
-static size_t conn_buf_posn;
48
-
49
-int fetch(unsigned char *sha1)
50
-{
51
- int ret;
52
- signed char remote;
53
- struct object_list *temp;
54
-
55
- if (hashcmp(sha1, in_transit->item->sha1)) {
56
- /* we must have already fetched it to clean the queue */
57
- return has_sha1_file(sha1) ? 0 : -1;
58
- }
59
- prefetches--;
60
- temp = in_transit;
61
- in_transit = in_transit->next;
62
- if (!in_transit)
63
- end_of_transit = &in_transit;
64
- free(temp);
65
-
66
- if (conn_buf_posn) {
67
- remote = conn_buf[0];
68
- memmove(conn_buf, conn_buf + 1, --conn_buf_posn);
69
- } else {
70
- if (xread(fd_in, &remote, 1) < 1)
71
- return -1;
72
- }
73
- /* fprintf(stderr, "Got %d\n", remote); */
74
- if (remote < 0)
75
- return remote;
76
- ret = write_sha1_from_fd(sha1, fd_in, conn_buf, 4096, &conn_buf_posn);
77
- if (!ret)
78
- pull_say("got %s\n", sha1_to_hex(sha1));
79
- return ret;
80
-}
81
-
82
-static int get_version(void)
83
-{
84
- char type = 'v';
85
- if (write_in_full(fd_out, &type, 1) != 1 ||
86
- write_in_full(fd_out, &local_version, 1)) {
87
- return error("Couldn't request version from remote end");
88
- }
89
- if (xread(fd_in, &remote_version, 1) < 1) {
90
- return error("Couldn't read version from remote end");
91
- }
92
- return 0;
93
-}
94
-
95
-int fetch_ref(char *ref, unsigned char *sha1)
96
-{
97
- signed char remote;
98
- char type = 'r';
99
- int length = strlen(ref) + 1;
100
- if (write_in_full(fd_out, &type, 1) != 1 ||
101
- write_in_full(fd_out, ref, length) != length)
102
- return -1;
103
-
104
- if (read_in_full(fd_in, &remote, 1) != 1)
105
- return -1;
106
- if (remote < 0)
107
- return remote;
108
- if (read_in_full(fd_in, sha1, 20) != 20)
109
- return -1;
110
- return 0;
111
-}
112
-
113
-static const char ssh_fetch_usage[] =
114
- MY_PROGRAM_NAME
115
- " [-c] [-t] [-a] [-v] [--recover] [-w ref] commit-id url";
116
-int main(int argc, char **argv)
117
-{
118
- const char *write_ref = NULL;
119
- char *commit_id;
120
- char *url;
121
- int arg = 1;
122
- const char *prog;
123
-
124
- prog = getenv("GIT_SSH_PUSH");
125
- if (!prog) prog = "git-ssh-upload";
126
-
127
- setup_git_directory();
128
- git_config(git_default_config);
129
-
130
- while (arg < argc && argv[arg][0] == '-') {
131
- if (argv[arg][1] == 't') {
132
- get_tree = 1;
133
- } else if (argv[arg][1] == 'c') {
134
- get_history = 1;
135
- } else if (argv[arg][1] == 'a') {
136
- get_all = 1;
137
- get_tree = 1;
138
- get_history = 1;
139
- } else if (argv[arg][1] == 'v') {
140
- get_verbosely = 1;
141
- } else if (argv[arg][1] == 'w') {
142
- write_ref = argv[arg + 1];
143
- arg++;
144
- } else if (!strcmp(argv[arg], "--recover")) {
145
- get_recover = 1;
146
- }
147
- arg++;
148
- }
149
- if (argc < arg + 2) {
150
- usage(ssh_fetch_usage);
151
- return 1;
152
- }
153
- commit_id = argv[arg];
154
- url = argv[arg + 1];
155
-
156
- if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
157
- return 1;
158
-
159
- if (get_version())
160
- return 1;
161
-
162
- if (pull(1, &commit_id, &write_ref, url))
163
- return 1;
164
-
165
- return 0;
166
-}
ssh-pull.c
deleted
-4
@@ -1,4 +0,0 @@
1
-#define COUNTERPART_ENV_NAME "GIT_SSH_PUSH"
2
-#define COUNTERPART_PROGRAM_NAME "git-ssh-push"
3
-#define MY_PROGRAM_NAME "git-ssh-pull"
4
-#include "ssh-fetch.c"
ssh-push.c
deleted
-4
@@ -1,4 +0,0 @@
1
-#define COUNTERPART_ENV_NAME "GIT_SSH_PULL"
2
-#define COUNTERPART_PROGRAM_NAME "git-ssh-pull"
3
-#define MY_PROGRAM_NAME "git-ssh-push"
4
-#include "ssh-upload.c"
ssh-upload.c
deleted
-143
@@ -1,143 +0,0 @@
1
-#ifndef COUNTERPART_ENV_NAME
2
-#define COUNTERPART_ENV_NAME "GIT_SSH_FETCH"
3
-#endif
4
-#ifndef COUNTERPART_PROGRAM_NAME
5
-#define COUNTERPART_PROGRAM_NAME "git-ssh-fetch"
6
-#endif
7
-#ifndef MY_PROGRAM_NAME
8
-#define MY_PROGRAM_NAME "git-ssh-upload"
9
-#endif
10
-
11
-#include "cache.h"
12
-#include "rsh.h"
13
-#include "refs.h"
14
-
15
-static unsigned char local_version = 1;
16
-static unsigned char remote_version;
17
-
18
-static int verbose;
19
-
20
-static int serve_object(int fd_in, int fd_out) {
21
- ssize_t size;
22
- unsigned char sha1[20];
23
- signed char remote;
24
-
25
- size = read_in_full(fd_in, sha1, 20);
26
- if (size < 0) {
27
- perror("git-ssh-upload: read ");
28
- return -1;
29
- }
30
- if (!size)
31
- return -1;
32
-
33
- if (verbose)
34
- fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1));
35
-
36
- remote = 0;
37
-
38
- if (!has_sha1_file(sha1)) {
39
- fprintf(stderr, "git-ssh-upload: could not find %s\n",
40
- sha1_to_hex(sha1));
41
- remote = -1;
42
- }
43
-
44
- if (write_in_full(fd_out, &remote, 1) != 1)
45
- return 0;
46
-
47
- if (remote < 0)
48
- return 0;
49
-
50
- return write_sha1_to_fd(fd_out, sha1);
51
-}
52
-
53
-static int serve_version(int fd_in, int fd_out)
54
-{
55
- if (xread(fd_in, &remote_version, 1) < 1)
56
- return -1;
57
- write_in_full(fd_out, &local_version, 1);
58
- return 0;
59
-}
60
-
61
-static int serve_ref(int fd_in, int fd_out)
62
-{
63
- char ref[PATH_MAX];
64
- unsigned char sha1[20];
65
- int posn = 0;
66
- signed char remote = 0;
67
- do {
68
- if (posn >= PATH_MAX || xread(fd_in, ref + posn, 1) < 1)
69
- return -1;
70
- posn++;
71
- } while (ref[posn - 1]);
72
-
73
- if (verbose)
74
- fprintf(stderr, "Serving %s\n", ref);
75
-
76
- if (get_ref_sha1(ref, sha1))
77
- remote = -1;
78
- if (write_in_full(fd_out, &remote, 1) != 1)
79
- return 0;
80
- if (remote)
81
- return 0;
82
- write_in_full(fd_out, sha1, 20);
83
- return 0;
84
-}
85
-
86
-
87
-static void service(int fd_in, int fd_out) {
88
- char type;
89
- ssize_t retval;
90
- do {
91
- retval = xread(fd_in, &type, 1);
92
- if (retval < 1) {
93
- if (retval < 0)
94
- perror("git-ssh-upload: read ");
95
- return;
96
- }
97
- if (type == 'v' && serve_version(fd_in, fd_out))
98
- return;
99
- if (type == 'o' && serve_object(fd_in, fd_out))
100
- return;
101
- if (type == 'r' && serve_ref(fd_in, fd_out))
102
- return;
103
- } while (1);
104
-}
105
-
106
-static const char ssh_push_usage[] =
107
- MY_PROGRAM_NAME " [-c] [-t] [-a] [-w ref] commit-id url";
108
-
109
-int main(int argc, char **argv)
110
-{
111
- int arg = 1;
112
- char *commit_id;
113
- char *url;
114
- int fd_in, fd_out;
115
- const char *prog;
116
- unsigned char sha1[20];
117
- char hex[41];
118
-
119
- prog = getenv(COUNTERPART_ENV_NAME);
120
- if (!prog) prog = COUNTERPART_PROGRAM_NAME;
121
-
122
- setup_git_directory();
123
-
124
- while (arg < argc && argv[arg][0] == '-') {
125
- if (argv[arg][1] == 'w')
126
- arg++;
127
- arg++;
128
- }
129
- if (argc < arg + 2)
130
- usage(ssh_push_usage);
131
- commit_id = argv[arg];
132
- url = argv[arg + 1];
133
- if (get_sha1(commit_id, sha1))
134
- die("Not a valid object name %s", commit_id);
135
- memcpy(hex, sha1_to_hex(sha1), sizeof(hex));
136
- argv[arg] = hex;
137
-
138
- if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
139
- return 1;
140
-
141
- service(fd_in, fd_out);
142
- return 0;
143
-}