Windows: Disambiguate DOS style paths from SSH URLs.
[git/git.git] / upload-pack.c
CommitLineData
def88e9a
LT
1#include "cache.h"
2#include "refs.h"
3#include "pkt-line.h"
958c24b1 4#include "sideband.h"
f6b42a81
JH
5#include "tag.h"
6#include "object.h"
f0243f26 7#include "commit.h"
77cb17e9 8#include "exec_cmd.h"
9b8dc263
JS
9#include "diff.h"
10#include "revision.h"
11#include "list-objects.h"
cc41fa8d 12#include "run-command.h"
def88e9a 13
960deccb 14static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
def88e9a 15
937a515a
JH
16/* bits #0..7 in revision.h, #8..10 in commit.c */
17#define THEY_HAVE (1u << 11)
18#define OUR_REF (1u << 12)
19#define WANTED (1u << 13)
20#define COMMON_KNOWN (1u << 14)
21#define REACHABLE (1u << 15)
22
f53514bc
JS
23#define SHALLOW (1u << 16)
24#define NOT_SHALLOW (1u << 17)
25#define CLIENT_SHALLOW (1u << 18)
26
3fbe2d54 27static unsigned long oldest_have;
937a515a 28
96f1e58f 29static int multi_ack, nr_our_refs;
348e390b
SP
30static int use_thin_pack, use_ofs_delta, use_include_tag;
31static int no_progress;
b1e9fff7
JH
32static struct object_array have_obj;
33static struct object_array want_obj;
96f1e58f 34static unsigned int timeout;
d47f3db7
JH
35/* 0 for no sideband,
36 * otherwise maximum packet size (up to 65520 bytes).
37 */
96f1e58f 38static int use_sideband;
49aaddd1 39static int debug_fd;
960deccb
PA
40
41static void reset_timeout(void)
42{
43 alarm(timeout);
44}
fb9040cc 45
75bfc6c2
LT
46static int strip(char *line, int len)
47{
48 if (len && line[len-1] == '\n')
49 line[--len] = 0;
50 return len;
51}
52
583b7ea3
JH
53static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
54{
958c24b1 55 if (use_sideband)
d47f3db7 56 return send_sideband(1, fd, data, sz, use_sideband);
958c24b1
JH
57 if (fd == 3)
58 /* emergency quit */
59 fd = 2;
60 if (fd == 2) {
93822c22 61 /* XXX: are we happy to lose stuff here? */
958c24b1
JH
62 xwrite(fd, data, sz);
63 return sz;
583b7ea3 64 }
958c24b1 65 return safe_write(fd, data, sz);
583b7ea3
JH
66}
67
16befb8b 68static FILE *pack_pipe = NULL;
9b8dc263
JS
69static void show_commit(struct commit *commit)
70{
71 if (commit->object.flags & BOUNDARY)
72 fputc('-', pack_pipe);
73 if (fputs(sha1_to_hex(commit->object.sha1), pack_pipe) < 0)
74 die("broken output pipe");
75 fputc('\n', pack_pipe);
76 fflush(pack_pipe);
77 free(commit->buffer);
78 commit->buffer = NULL;
79}
80
81static void show_object(struct object_array_entry *p)
82{
83 /* An object with name "foo\n0000000..." can be used to
84 * confuse downstream git-pack-objects very badly.
85 */
86 const char *ep = strchr(p->name, '\n');
87 if (ep) {
88 fprintf(pack_pipe, "%s %.*s\n", sha1_to_hex(p->item->sha1),
89 (int) (ep - p->name),
90 p->name);
91 }
92 else
93 fprintf(pack_pipe, "%s %s\n",
94 sha1_to_hex(p->item->sha1), p->name);
95}
96
97static void show_edge(struct commit *commit)
98{
99 fprintf(pack_pipe, "-%s\n", sha1_to_hex(commit->object.sha1));
100}
101
21edd3f1 102static int do_rev_list(int fd, void *create_full_pack)
80ccaa78
JS
103{
104 int i;
105 struct rev_info revs;
106
21edd3f1 107 pack_pipe = fdopen(fd, "w");
80ccaa78
JS
108 if (create_full_pack)
109 use_thin_pack = 0; /* no point doing it */
110 init_revisions(&revs, NULL);
111 revs.tag_objects = 1;
112 revs.tree_objects = 1;
113 revs.blob_objects = 1;
114 if (use_thin_pack)
115 revs.edge_hint = 1;
116
117 if (create_full_pack) {
118 const char *args[] = {"rev-list", "--all", NULL};
119 setup_revisions(2, args, &revs, NULL);
120 } else {
121 for (i = 0; i < want_obj.nr; i++) {
122 struct object *o = want_obj.objects[i].item;
123 /* why??? */
124 o->flags &= ~UNINTERESTING;
125 add_pending_object(&revs, o, NULL);
126 }
127 for (i = 0; i < have_obj.nr; i++) {
128 struct object *o = have_obj.objects[i].item;
129 o->flags |= UNINTERESTING;
130 add_pending_object(&revs, o, NULL);
131 }
132 setup_revisions(0, NULL, &revs, NULL);
133 }
3d51e1b5
MK
134 if (prepare_revision_walk(&revs))
135 die("revision walk setup failed");
80ccaa78
JS
136 mark_edges_uninteresting(revs.commits, &revs, show_edge);
137 traverse_commit_list(&revs, show_commit, show_object);
21edd3f1 138 return 0;
80ccaa78
JS
139}
140
fb9040cc
LT
141static void create_pack_file(void)
142{
21edd3f1 143 struct async rev_list;
cc41fa8d 144 struct child_process pack_objects;
b1e9fff7 145 int create_full_pack = (nr_our_refs == want_obj.nr && !have_obj.nr);
363b7817 146 char data[8193], progress[128];
583b7ea3
JH
147 char abort_msg[] = "aborting due to possible repository "
148 "corruption on the remote side.";
b1c71b72 149 int buffered = -1;
4c324c00 150 ssize_t sz;
cc41fa8d
JS
151 const char *argv[10];
152 int arg = 0;
75bfc6c2 153
21edd3f1
JS
154 rev_list.proc = do_rev_list;
155 /* .data is just a boolean: any non-NULL value will do */
156 rev_list.data = create_full_pack ? &rev_list : NULL;
157 if (start_async(&rev_list))
75bfc6c2
LT
158 die("git-upload-pack: unable to fork git-rev-list");
159
cc41fa8d
JS
160 argv[arg++] = "pack-objects";
161 argv[arg++] = "--stdout";
162 if (!no_progress)
163 argv[arg++] = "--progress";
164 if (use_ofs_delta)
165 argv[arg++] = "--delta-base-offset";
348e390b
SP
166 if (use_include_tag)
167 argv[arg++] = "--include-tag";
cc41fa8d
JS
168 argv[arg++] = NULL;
169
170 memset(&pack_objects, 0, sizeof(pack_objects));
21edd3f1 171 pack_objects.in = rev_list.out; /* start_command closes it */
cc41fa8d
JS
172 pack_objects.out = -1;
173 pack_objects.err = -1;
174 pack_objects.git_cmd = 1;
175 pack_objects.argv = argv;
21edd3f1 176
4c324c00 177 if (start_command(&pack_objects))
b1c71b72 178 die("git-upload-pack: unable to fork git-pack-objects");
b1c71b72 179
cc41fa8d
JS
180 /* We read from pack_objects.err to capture stderr output for
181 * progress bar, and pack_objects.out to capture the pack data.
b1c71b72 182 */
b1c71b72
JH
183
184 while (1) {
b1c71b72 185 struct pollfd pfd[2];
363b7817 186 int pe, pu, pollsize;
b1c71b72 187
0d516ada
ML
188 reset_timeout();
189
b1c71b72 190 pollsize = 0;
363b7817 191 pe = pu = -1;
b1c71b72 192
cc41fa8d
JS
193 if (0 <= pack_objects.out) {
194 pfd[pollsize].fd = pack_objects.out;
b1c71b72
JH
195 pfd[pollsize].events = POLLIN;
196 pu = pollsize;
197 pollsize++;
198 }
cc41fa8d
JS
199 if (0 <= pack_objects.err) {
200 pfd[pollsize].fd = pack_objects.err;
363b7817
JH
201 pfd[pollsize].events = POLLIN;
202 pe = pollsize;
203 pollsize++;
204 }
b1c71b72 205
4c324c00
JS
206 if (!pollsize)
207 break;
208
209 if (poll(pfd, pollsize, -1) < 0) {
210 if (errno != EINTR) {
211 error("poll failed, resuming: %s",
212 strerror(errno));
213 sleep(1);
b1c71b72 214 }
4c324c00
JS
215 continue;
216 }
217 if (0 <= pu && (pfd[pu].revents & (POLLIN|POLLHUP))) {
218 /* Data ready; we keep the last byte to ourselves
219 * in case we detect broken rev-list, so that we
220 * can leave the stream corrupted. This is
221 * unfortunate -- unpack-objects would happily
222 * accept a valid packdata with trailing garbage,
223 * so appending garbage after we pass all the
224 * pack data is not good enough to signal
225 * breakage to downstream.
226 */
227 char *cp = data;
228 ssize_t outsz = 0;
229 if (0 <= buffered) {
230 *cp++ = buffered;
231 outsz++;
b1c71b72 232 }
4c324c00
JS
233 sz = xread(pack_objects.out, cp,
234 sizeof(data) - outsz);
235 if (0 < sz)
236 ;
237 else if (sz == 0) {
238 close(pack_objects.out);
239 pack_objects.out = -1;
363b7817 240 }
4c324c00
JS
241 else
242 goto fail;
243 sz += outsz;
244 if (1 < sz) {
245 buffered = data[sz-1] & 0xFF;
246 sz--;
b1c71b72 247 }
4c324c00
JS
248 else
249 buffered = -1;
250 sz = send_client_data(1, data, sz);
251 if (sz < 0)
b1c71b72 252 goto fail;
4c324c00
JS
253 }
254 if (0 <= pe && (pfd[pe].revents & (POLLIN|POLLHUP))) {
255 /* Status ready; we ship that in the side-band
256 * or dump to the standard error.
257 */
258 sz = xread(pack_objects.err, progress,
259 sizeof(progress));
260 if (0 < sz)
261 send_client_data(2, progress, sz);
262 else if (sz == 0) {
263 close(pack_objects.err);
264 pack_objects.err = -1;
b1c71b72 265 }
4c324c00
JS
266 else
267 goto fail;
b1c71b72 268 }
4c324c00 269 }
b1c71b72 270
4c324c00
JS
271 if (finish_command(&pack_objects)) {
272 error("git-upload-pack: git-pack-objects died with error.");
273 goto fail;
274 }
275 if (finish_async(&rev_list))
276 goto fail; /* error was already reported */
b1c71b72 277
4c324c00
JS
278 /* flush the data */
279 if (0 <= buffered) {
280 data[0] = buffered;
281 sz = send_client_data(1, data, 1);
282 if (sz < 0)
283 goto fail;
284 fprintf(stderr, "flushed.\n");
b1c71b72 285 }
4c324c00
JS
286 if (use_sideband)
287 packet_flush(1);
288 return;
289
b1c71b72 290 fail:
583b7ea3
JH
291 send_client_data(3, abort_msg, sizeof(abort_msg));
292 die("git-upload-pack: %s", abort_msg);
fb9040cc
LT
293}
294
def88e9a
LT
295static int got_sha1(char *hex, unsigned char *sha1)
296{
b1e9fff7 297 struct object *o;
937a515a 298 int we_knew_they_have = 0;
b1e9fff7 299
def88e9a
LT
300 if (get_sha1_hex(hex, sha1))
301 die("git-upload-pack: expected SHA1 object, got '%s'", hex);
fb9040cc 302 if (!has_sha1_file(sha1))
937a515a 303 return -1;
b1e9fff7
JH
304
305 o = lookup_object(sha1);
306 if (!(o && o->parsed))
307 o = parse_object(sha1);
308 if (!o)
309 die("oops (%s)", sha1_to_hex(sha1));
182a8dab 310 if (o->type == OBJ_COMMIT) {
b1e9fff7 311 struct commit_list *parents;
937a515a 312 struct commit *commit = (struct commit *)o;
b1e9fff7 313 if (o->flags & THEY_HAVE)
937a515a
JH
314 we_knew_they_have = 1;
315 else
316 o->flags |= THEY_HAVE;
317 if (!oldest_have || (commit->date < oldest_have))
318 oldest_have = commit->date;
319 for (parents = commit->parents;
b1e9fff7
JH
320 parents;
321 parents = parents->next)
322 parents->item->object.flags |= THEY_HAVE;
fb9040cc 323 }
937a515a
JH
324 if (!we_knew_they_have) {
325 add_object_array(o, NULL, &have_obj);
326 return 1;
327 }
328 return 0;
329}
330
331static int reachable(struct commit *want)
332{
333 struct commit_list *work = NULL;
334
335 insert_by_date(want, &work);
336 while (work) {
337 struct commit_list *list = work->next;
338 struct commit *commit = work->item;
339 free(work);
340 work = list;
341
342 if (commit->object.flags & THEY_HAVE) {
343 want->object.flags |= COMMON_KNOWN;
344 break;
345 }
346 if (!commit->object.parsed)
347 parse_object(commit->object.sha1);
348 if (commit->object.flags & REACHABLE)
349 continue;
350 commit->object.flags |= REACHABLE;
351 if (commit->date < oldest_have)
352 continue;
353 for (list = commit->parents; list; list = list->next) {
354 struct commit *parent = list->item;
355 if (!(parent->object.flags & REACHABLE))
356 insert_by_date(parent, &work);
357 }
358 }
359 want->object.flags |= REACHABLE;
360 clear_commit_marks(want, REACHABLE);
361 free_commit_list(work);
362 return (want->object.flags & COMMON_KNOWN);
363}
364
365static int ok_to_give_up(void)
366{
367 int i;
368
369 if (!have_obj.nr)
370 return 0;
371
372 for (i = 0; i < want_obj.nr; i++) {
373 struct object *want = want_obj.objects[i].item;
374
375 if (want->flags & COMMON_KNOWN)
376 continue;
377 want = deref_tag(want, "a want line", 0);
378 if (!want || want->type != OBJ_COMMIT) {
379 /* no way to tell if this is reachable by
380 * looking at the ancestry chain alone, so
381 * leave a note to ourselves not to worry about
382 * this object anymore.
383 */
384 want_obj.objects[i].item->flags |= COMMON_KNOWN;
385 continue;
386 }
387 if (!reachable((struct commit *)want))
388 return 0;
389 }
fb9040cc 390 return 1;
def88e9a
LT
391}
392
393static int get_common_commits(void)
394{
395 static char line[1000];
c04c4e57
JH
396 unsigned char sha1[20];
397 char hex[41], last_hex[41];
def88e9a
LT
398 int len;
399
f0243f26
JS
400 save_commit_buffer = 0;
401
def88e9a
LT
402 for(;;) {
403 len = packet_read_line(0, line, sizeof(line));
960deccb 404 reset_timeout();
def88e9a
LT
405
406 if (!len) {
b1e9fff7 407 if (have_obj.nr == 0 || multi_ack)
1bd8c8f0 408 packet_write(1, "NAK\n");
def88e9a
LT
409 continue;
410 }
75bfc6c2 411 len = strip(line, len);
cc44c765 412 if (!prefixcmp(line, "have ")) {
937a515a
JH
413 switch (got_sha1(line+5, sha1)) {
414 case -1: /* they have what we do not */
415 if (multi_ack && ok_to_give_up())
416 packet_write(1, "ACK %s continue\n",
417 sha1_to_hex(sha1));
418 break;
419 default:
c04c4e57
JH
420 memcpy(hex, sha1_to_hex(sha1), 41);
421 if (multi_ack) {
422 const char *msg = "ACK %s continue\n";
423 packet_write(1, msg, hex);
424 memcpy(last_hex, hex, 41);
425 }
426 else if (have_obj.nr == 1)
427 packet_write(1, "ACK %s\n", hex);
937a515a 428 break;
af2d3aa4 429 }
def88e9a
LT
430 continue;
431 }
432 if (!strcmp(line, "done")) {
b1e9fff7 433 if (have_obj.nr > 0) {
1bd8c8f0 434 if (multi_ack)
c04c4e57 435 packet_write(1, "ACK %s\n", last_hex);
1bd8c8f0
JS
436 return 0;
437 }
def88e9a
LT
438 packet_write(1, "NAK\n");
439 return -1;
440 }
441 die("git-upload-pack: expected SHA1 list, got '%s'", line);
442 }
def88e9a
LT
443}
444
b1e9fff7 445static void receive_needs(void)
fb9040cc 446{
ed09aef0 447 struct object_array shallows = {0, 0, NULL};
fb9040cc 448 static char line[1000];
016e6ccb 449 int len, depth = 0;
fb9040cc 450
49aaddd1
SP
451 if (debug_fd)
452 write_in_full(debug_fd, "#S\n", 3);
fb9040cc 453 for (;;) {
565ebbf7 454 struct object *o;
6ece0d30 455 unsigned char sha1_buf[20];
fb9040cc 456 len = packet_read_line(0, line, sizeof(line));
960deccb 457 reset_timeout();
fb9040cc 458 if (!len)
ed09aef0 459 break;
49aaddd1
SP
460 if (debug_fd)
461 write_in_full(debug_fd, line, len);
e091eb93 462
599065a3 463 if (!prefixcmp(line, "shallow ")) {
ed09aef0
JS
464 unsigned char sha1[20];
465 struct object *object;
f53514bc 466 use_thin_pack = 0;
ed09aef0
JS
467 if (get_sha1(line + 8, sha1))
468 die("invalid shallow line: %s", line);
469 object = parse_object(sha1);
470 if (!object)
471 die("did not find object for %s", line);
f53514bc 472 object->flags |= CLIENT_SHALLOW;
ed09aef0
JS
473 add_object_array(object, NULL, &shallows);
474 continue;
475 }
599065a3 476 if (!prefixcmp(line, "deepen ")) {
016e6ccb 477 char *end;
f53514bc 478 use_thin_pack = 0;
016e6ccb
JS
479 depth = strtol(line + 7, &end, 0);
480 if (end == line + 7 || depth <= 0)
481 die("Invalid deepen: %s", line);
482 continue;
483 }
599065a3 484 if (prefixcmp(line, "want ") ||
6ece0d30 485 get_sha1_hex(line+5, sha1_buf))
e091eb93
JH
486 die("git-upload-pack: protocol error, "
487 "expected to get sha, not '%s'", line);
1bd8c8f0
JS
488 if (strstr(line+45, "multi_ack"))
489 multi_ack = 1;
b19696c2
JH
490 if (strstr(line+45, "thin-pack"))
491 use_thin_pack = 1;
e4fe4b8e
NP
492 if (strstr(line+45, "ofs-delta"))
493 use_ofs_delta = 1;
d47f3db7
JH
494 if (strstr(line+45, "side-band-64k"))
495 use_sideband = LARGE_PACKET_MAX;
496 else if (strstr(line+45, "side-band"))
497 use_sideband = DEFAULT_PACKET_MAX;
b0e90897
JS
498 if (strstr(line+45, "no-progress"))
499 no_progress = 1;
348e390b
SP
500 if (strstr(line+45, "include-tag"))
501 use_include_tag = 1;
565ebbf7
JH
502
503 /* We have sent all our refs already, and the other end
504 * should have chosen out of them; otherwise they are
505 * asking for nonsense.
506 *
507 * Hmph. We may later want to allow "want" line that
508 * asks for something like "master~10" (symbolic)...
509 * would it make sense? I don't know.
510 */
511 o = lookup_object(sha1_buf);
512 if (!o || !(o->flags & OUR_REF))
513 die("git-upload-pack: not our ref %s", line+5);
514 if (!(o->flags & WANTED)) {
515 o->flags |= WANTED;
b1e9fff7 516 add_object_array(o, NULL, &want_obj);
565ebbf7 517 }
fb9040cc 518 }
49aaddd1
SP
519 if (debug_fd)
520 write_in_full(debug_fd, "#E\n", 3);
f53514bc
JS
521 if (depth == 0 && shallows.nr == 0)
522 return;
016e6ccb
JS
523 if (depth > 0) {
524 struct commit_list *result, *backup;
f53514bc
JS
525 int i;
526 backup = result = get_shallow_commits(&want_obj, depth,
527 SHALLOW, NOT_SHALLOW);
016e6ccb 528 while (result) {
f53514bc 529 struct object *object = &result->item->object;
1f2de769 530 if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
f53514bc
JS
531 packet_write(1, "shallow %s",
532 sha1_to_hex(object->sha1));
533 register_shallow(object->sha1);
534 }
016e6ccb
JS
535 result = result->next;
536 }
537 free_commit_list(backup);
f53514bc
JS
538 for (i = 0; i < shallows.nr; i++) {
539 struct object *object = shallows.objects[i].item;
540 if (object->flags & NOT_SHALLOW) {
541 struct commit_list *parents;
542 packet_write(1, "unshallow %s",
543 sha1_to_hex(object->sha1));
544 object->flags &= ~CLIENT_SHALLOW;
545 /* make sure the real parents are parsed */
546 unregister_shallow(object->sha1);
176d45cb 547 object->parsed = 0;
dec38c81
MK
548 if (parse_commit((struct commit *)object))
549 die("invalid commit");
f53514bc
JS
550 parents = ((struct commit *)object)->parents;
551 while (parents) {
552 add_object_array(&parents->item->object,
553 NULL, &want_obj);
554 parents = parents->next;
555 }
556 }
557 /* make sure commit traversal conforms to client */
558 register_shallow(object->sha1);
559 }
560 packet_flush(1);
561 } else
562 if (shallows.nr > 0) {
563 int i;
564 for (i = 0; i < shallows.nr; i++)
565 register_shallow(shallows.objects[i].item->sha1);
566 }
567 free(shallows.objects);
fb9040cc
LT
568}
569
8da19775 570static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
def88e9a 571{
ed09aef0 572 static const char *capabilities = "multi_ack thin-pack side-band"
348e390b
SP
573 " side-band-64k ofs-delta shallow no-progress"
574 " include-tag";
f6b42a81
JH
575 struct object *o = parse_object(sha1);
576
b5b16990
CW
577 if (!o)
578 die("git-upload-pack: cannot find object %s:", sha1_to_hex(sha1));
579
1f5881bb
JS
580 if (capabilities)
581 packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
582 0, capabilities);
583 else
584 packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname);
585 capabilities = NULL;
565ebbf7
JH
586 if (!(o->flags & OUR_REF)) {
587 o->flags |= OUR_REF;
588 nr_our_refs++;
589 }
1974632c 590 if (o->type == OBJ_TAG) {
9534f40b 591 o = deref_tag(o, refname, 0);
affeef12
MK
592 if (o)
593 packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
f6b42a81 594 }
def88e9a
LT
595 return 0;
596}
597
59076eba 598static void upload_pack(void)
def88e9a 599{
960deccb 600 reset_timeout();
cb5d709f
JH
601 head_ref(send_ref, NULL);
602 for_each_ref(send_ref, NULL);
def88e9a 603 packet_flush(1);
b1e9fff7 604 receive_needs();
59076eba
DR
605 if (want_obj.nr) {
606 get_common_commits();
607 create_pack_file();
608 }
def88e9a
LT
609}
610
611int main(int argc, char **argv)
612{
8d630132 613 char *dir;
960deccb
PA
614 int i;
615 int strict = 0;
616
617 for (i = 1; i < argc; i++) {
618 char *arg = argv[i];
619
620 if (arg[0] != '-')
621 break;
622 if (!strcmp(arg, "--strict")) {
623 strict = 1;
624 continue;
625 }
cc44c765 626 if (!prefixcmp(arg, "--timeout=")) {
960deccb
PA
627 timeout = atoi(arg+10);
628 continue;
629 }
630 if (!strcmp(arg, "--")) {
631 i++;
632 break;
633 }
634 }
a6080a0a 635
960deccb 636 if (i != argc-1)
def88e9a 637 usage(upload_pack_usage);
04b33055
JS
638
639 setup_path(NULL);
640
960deccb 641 dir = argv[i];
113b9475 642
8d630132
AE
643 if (!enter_repo(dir, strict))
644 die("'%s': unable to chdir or not a git archive", dir);
a0022eeb
JH
645 if (is_repository_shallow())
646 die("attempt to fetch/clone from a shallow repository");
49aaddd1
SP
647 if (getenv("GIT_DEBUG_SEND_PACK"))
648 debug_fd = atoi(getenv("GIT_DEBUG_SEND_PACK"));
def88e9a
LT
649 upload_pack();
650 return 0;
651}