t: pass GIT_TRACE through Apache
[git/mingw/j6t.git] / upload-pack.c
blobb531a325d2864e94bdc86e689f78663255bb7cf2
1 #include "cache.h"
2 #include "refs.h"
3 #include "pkt-line.h"
4 #include "sideband.h"
5 #include "tag.h"
6 #include "object.h"
7 #include "commit.h"
8 #include "exec_cmd.h"
9 #include "diff.h"
10 #include "revision.h"
11 #include "list-objects.h"
12 #include "run-command.h"
13 #include "connect.h"
14 #include "sigchain.h"
15 #include "version.h"
16 #include "string-list.h"
18 static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<n>] <dir>";
20 /* Remember to update object flag allocation in object.h */
21 #define THEY_HAVE (1u << 11)
22 #define OUR_REF (1u << 12)
23 #define WANTED (1u << 13)
24 #define COMMON_KNOWN (1u << 14)
25 #define REACHABLE (1u << 15)
27 #define SHALLOW (1u << 16)
28 #define NOT_SHALLOW (1u << 17)
29 #define CLIENT_SHALLOW (1u << 18)
30 #define HIDDEN_REF (1u << 19)
32 static unsigned long oldest_have;
34 static int multi_ack;
35 static int no_done;
36 static int use_thin_pack, use_ofs_delta, use_include_tag;
37 static int no_progress, daemon_mode;
38 static int allow_tip_sha1_in_want;
39 static int shallow_nr;
40 static struct object_array have_obj;
41 static struct object_array want_obj;
42 static struct object_array extra_edge_obj;
43 static unsigned int timeout;
44 static int keepalive = 5;
45 /* 0 for no sideband,
46 * otherwise maximum packet size (up to 65520 bytes).
48 static int use_sideband;
49 static int advertise_refs;
50 static int stateless_rpc;
52 static void reset_timeout(void)
54 alarm(timeout);
57 static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
59 if (use_sideband)
60 return send_sideband(1, fd, data, sz, use_sideband);
61 if (fd == 3)
62 /* emergency quit */
63 fd = 2;
64 if (fd == 2) {
65 /* XXX: are we happy to lose stuff here? */
66 xwrite(fd, data, sz);
67 return sz;
69 write_or_die(fd, data, sz);
70 return sz;
73 static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
75 FILE *fp = cb_data;
76 if (graft->nr_parent == -1)
77 fprintf(fp, "--shallow %s\n", sha1_to_hex(graft->sha1));
78 return 0;
81 static void create_pack_file(void)
83 struct child_process pack_objects = CHILD_PROCESS_INIT;
84 char data[8193], progress[128];
85 char abort_msg[] = "aborting due to possible repository "
86 "corruption on the remote side.";
87 int buffered = -1;
88 ssize_t sz;
89 const char *argv[13];
90 int i, arg = 0;
91 FILE *pipe_fd;
93 if (shallow_nr) {
94 argv[arg++] = "--shallow-file";
95 argv[arg++] = "";
97 argv[arg++] = "pack-objects";
98 argv[arg++] = "--revs";
99 if (use_thin_pack)
100 argv[arg++] = "--thin";
102 argv[arg++] = "--stdout";
103 if (shallow_nr)
104 argv[arg++] = "--shallow";
105 if (!no_progress)
106 argv[arg++] = "--progress";
107 if (use_ofs_delta)
108 argv[arg++] = "--delta-base-offset";
109 if (use_include_tag)
110 argv[arg++] = "--include-tag";
111 argv[arg++] = NULL;
113 pack_objects.in = -1;
114 pack_objects.out = -1;
115 pack_objects.err = -1;
116 pack_objects.git_cmd = 1;
117 pack_objects.argv = argv;
119 if (start_command(&pack_objects))
120 die("git upload-pack: unable to fork git-pack-objects");
122 pipe_fd = xfdopen(pack_objects.in, "w");
124 if (shallow_nr)
125 for_each_commit_graft(write_one_shallow, pipe_fd);
127 for (i = 0; i < want_obj.nr; i++)
128 fprintf(pipe_fd, "%s\n",
129 sha1_to_hex(want_obj.objects[i].item->sha1));
130 fprintf(pipe_fd, "--not\n");
131 for (i = 0; i < have_obj.nr; i++)
132 fprintf(pipe_fd, "%s\n",
133 sha1_to_hex(have_obj.objects[i].item->sha1));
134 for (i = 0; i < extra_edge_obj.nr; i++)
135 fprintf(pipe_fd, "%s\n",
136 sha1_to_hex(extra_edge_obj.objects[i].item->sha1));
137 fprintf(pipe_fd, "\n");
138 fflush(pipe_fd);
139 fclose(pipe_fd);
141 /* We read from pack_objects.err to capture stderr output for
142 * progress bar, and pack_objects.out to capture the pack data.
145 while (1) {
146 struct pollfd pfd[2];
147 int pe, pu, pollsize;
148 int ret;
150 reset_timeout();
152 pollsize = 0;
153 pe = pu = -1;
155 if (0 <= pack_objects.out) {
156 pfd[pollsize].fd = pack_objects.out;
157 pfd[pollsize].events = POLLIN;
158 pu = pollsize;
159 pollsize++;
161 if (0 <= pack_objects.err) {
162 pfd[pollsize].fd = pack_objects.err;
163 pfd[pollsize].events = POLLIN;
164 pe = pollsize;
165 pollsize++;
168 if (!pollsize)
169 break;
171 ret = poll(pfd, pollsize,
172 keepalive < 0 ? -1 : 1000 * keepalive);
174 if (ret < 0) {
175 if (errno != EINTR) {
176 error("poll failed, resuming: %s",
177 strerror(errno));
178 sleep(1);
180 continue;
182 if (0 <= pe && (pfd[pe].revents & (POLLIN|POLLHUP))) {
183 /* Status ready; we ship that in the side-band
184 * or dump to the standard error.
186 sz = xread(pack_objects.err, progress,
187 sizeof(progress));
188 if (0 < sz)
189 send_client_data(2, progress, sz);
190 else if (sz == 0) {
191 close(pack_objects.err);
192 pack_objects.err = -1;
194 else
195 goto fail;
196 /* give priority to status messages */
197 continue;
199 if (0 <= pu && (pfd[pu].revents & (POLLIN|POLLHUP))) {
200 /* Data ready; we keep the last byte to ourselves
201 * in case we detect broken rev-list, so that we
202 * can leave the stream corrupted. This is
203 * unfortunate -- unpack-objects would happily
204 * accept a valid packdata with trailing garbage,
205 * so appending garbage after we pass all the
206 * pack data is not good enough to signal
207 * breakage to downstream.
209 char *cp = data;
210 ssize_t outsz = 0;
211 if (0 <= buffered) {
212 *cp++ = buffered;
213 outsz++;
215 sz = xread(pack_objects.out, cp,
216 sizeof(data) - outsz);
217 if (0 < sz)
219 else if (sz == 0) {
220 close(pack_objects.out);
221 pack_objects.out = -1;
223 else
224 goto fail;
225 sz += outsz;
226 if (1 < sz) {
227 buffered = data[sz-1] & 0xFF;
228 sz--;
230 else
231 buffered = -1;
232 sz = send_client_data(1, data, sz);
233 if (sz < 0)
234 goto fail;
238 * We hit the keepalive timeout without saying anything; send
239 * an empty message on the data sideband just to let the other
240 * side know we're still working on it, but don't have any data
241 * yet.
243 * If we don't have a sideband channel, there's no room in the
244 * protocol to say anything, so those clients are just out of
245 * luck.
247 if (!ret && use_sideband) {
248 static const char buf[] = "0005\1";
249 write_or_die(1, buf, 5);
253 if (finish_command(&pack_objects)) {
254 error("git upload-pack: git-pack-objects died with error.");
255 goto fail;
258 /* flush the data */
259 if (0 <= buffered) {
260 data[0] = buffered;
261 sz = send_client_data(1, data, 1);
262 if (sz < 0)
263 goto fail;
264 fprintf(stderr, "flushed.\n");
266 if (use_sideband)
267 packet_flush(1);
268 return;
270 fail:
271 send_client_data(3, abort_msg, sizeof(abort_msg));
272 die("git upload-pack: %s", abort_msg);
275 static int got_sha1(char *hex, unsigned char *sha1)
277 struct object *o;
278 int we_knew_they_have = 0;
280 if (get_sha1_hex(hex, sha1))
281 die("git upload-pack: expected SHA1 object, got '%s'", hex);
282 if (!has_sha1_file(sha1))
283 return -1;
285 o = parse_object(sha1);
286 if (!o)
287 die("oops (%s)", sha1_to_hex(sha1));
288 if (o->type == OBJ_COMMIT) {
289 struct commit_list *parents;
290 struct commit *commit = (struct commit *)o;
291 if (o->flags & THEY_HAVE)
292 we_knew_they_have = 1;
293 else
294 o->flags |= THEY_HAVE;
295 if (!oldest_have || (commit->date < oldest_have))
296 oldest_have = commit->date;
297 for (parents = commit->parents;
298 parents;
299 parents = parents->next)
300 parents->item->object.flags |= THEY_HAVE;
302 if (!we_knew_they_have) {
303 add_object_array(o, NULL, &have_obj);
304 return 1;
306 return 0;
309 static int reachable(struct commit *want)
311 struct commit_list *work = NULL;
313 commit_list_insert_by_date(want, &work);
314 while (work) {
315 struct commit_list *list = work->next;
316 struct commit *commit = work->item;
317 free(work);
318 work = list;
320 if (commit->object.flags & THEY_HAVE) {
321 want->object.flags |= COMMON_KNOWN;
322 break;
324 if (!commit->object.parsed)
325 parse_object(commit->object.sha1);
326 if (commit->object.flags & REACHABLE)
327 continue;
328 commit->object.flags |= REACHABLE;
329 if (commit->date < oldest_have)
330 continue;
331 for (list = commit->parents; list; list = list->next) {
332 struct commit *parent = list->item;
333 if (!(parent->object.flags & REACHABLE))
334 commit_list_insert_by_date(parent, &work);
337 want->object.flags |= REACHABLE;
338 clear_commit_marks(want, REACHABLE);
339 free_commit_list(work);
340 return (want->object.flags & COMMON_KNOWN);
343 static int ok_to_give_up(void)
345 int i;
347 if (!have_obj.nr)
348 return 0;
350 for (i = 0; i < want_obj.nr; i++) {
351 struct object *want = want_obj.objects[i].item;
353 if (want->flags & COMMON_KNOWN)
354 continue;
355 want = deref_tag(want, "a want line", 0);
356 if (!want || want->type != OBJ_COMMIT) {
357 /* no way to tell if this is reachable by
358 * looking at the ancestry chain alone, so
359 * leave a note to ourselves not to worry about
360 * this object anymore.
362 want_obj.objects[i].item->flags |= COMMON_KNOWN;
363 continue;
365 if (!reachable((struct commit *)want))
366 return 0;
368 return 1;
371 static int get_common_commits(void)
373 unsigned char sha1[20];
374 char last_hex[41];
375 int got_common = 0;
376 int got_other = 0;
377 int sent_ready = 0;
379 save_commit_buffer = 0;
381 for (;;) {
382 char *line = packet_read_line(0, NULL);
383 reset_timeout();
385 if (!line) {
386 if (multi_ack == 2 && got_common
387 && !got_other && ok_to_give_up()) {
388 sent_ready = 1;
389 packet_write(1, "ACK %s ready\n", last_hex);
391 if (have_obj.nr == 0 || multi_ack)
392 packet_write(1, "NAK\n");
394 if (no_done && sent_ready) {
395 packet_write(1, "ACK %s\n", last_hex);
396 return 0;
398 if (stateless_rpc)
399 exit(0);
400 got_common = 0;
401 got_other = 0;
402 continue;
404 if (starts_with(line, "have ")) {
405 switch (got_sha1(line+5, sha1)) {
406 case -1: /* they have what we do not */
407 got_other = 1;
408 if (multi_ack && ok_to_give_up()) {
409 const char *hex = sha1_to_hex(sha1);
410 if (multi_ack == 2) {
411 sent_ready = 1;
412 packet_write(1, "ACK %s ready\n", hex);
413 } else
414 packet_write(1, "ACK %s continue\n", hex);
416 break;
417 default:
418 got_common = 1;
419 memcpy(last_hex, sha1_to_hex(sha1), 41);
420 if (multi_ack == 2)
421 packet_write(1, "ACK %s common\n", last_hex);
422 else if (multi_ack)
423 packet_write(1, "ACK %s continue\n", last_hex);
424 else if (have_obj.nr == 1)
425 packet_write(1, "ACK %s\n", last_hex);
426 break;
428 continue;
430 if (!strcmp(line, "done")) {
431 if (have_obj.nr > 0) {
432 if (multi_ack)
433 packet_write(1, "ACK %s\n", last_hex);
434 return 0;
436 packet_write(1, "NAK\n");
437 return -1;
439 die("git upload-pack: expected SHA1 list, got '%s'", line);
443 static int is_our_ref(struct object *o)
445 return o->flags &
446 ((allow_tip_sha1_in_want ? HIDDEN_REF : 0) | OUR_REF);
449 static void check_non_tip(void)
451 static const char *argv[] = {
452 "rev-list", "--stdin", NULL,
454 static struct child_process cmd = CHILD_PROCESS_INIT;
455 struct object *o;
456 char namebuf[42]; /* ^ + SHA-1 + LF */
457 int i;
459 /* In the normal in-process case non-tip request can never happen */
460 if (!stateless_rpc)
461 goto error;
463 cmd.argv = argv;
464 cmd.git_cmd = 1;
465 cmd.no_stderr = 1;
466 cmd.in = -1;
467 cmd.out = -1;
469 if (start_command(&cmd))
470 goto error;
473 * If rev-list --stdin encounters an unknown commit, it
474 * terminates, which will cause SIGPIPE in the write loop
475 * below.
477 sigchain_push(SIGPIPE, SIG_IGN);
479 namebuf[0] = '^';
480 namebuf[41] = '\n';
481 for (i = get_max_object_index(); 0 < i; ) {
482 o = get_indexed_object(--i);
483 if (!o)
484 continue;
485 if (!is_our_ref(o))
486 continue;
487 memcpy(namebuf + 1, sha1_to_hex(o->sha1), 40);
488 if (write_in_full(cmd.in, namebuf, 42) < 0)
489 goto error;
491 namebuf[40] = '\n';
492 for (i = 0; i < want_obj.nr; i++) {
493 o = want_obj.objects[i].item;
494 if (is_our_ref(o))
495 continue;
496 memcpy(namebuf, sha1_to_hex(o->sha1), 40);
497 if (write_in_full(cmd.in, namebuf, 41) < 0)
498 goto error;
500 close(cmd.in);
502 sigchain_pop(SIGPIPE);
505 * The commits out of the rev-list are not ancestors of
506 * our ref.
508 i = read_in_full(cmd.out, namebuf, 1);
509 if (i)
510 goto error;
511 close(cmd.out);
514 * rev-list may have died by encountering a bad commit
515 * in the history, in which case we do want to bail out
516 * even when it showed no commit.
518 if (finish_command(&cmd))
519 goto error;
521 /* All the non-tip ones are ancestors of what we advertised */
522 return;
524 error:
525 /* Pick one of them (we know there at least is one) */
526 for (i = 0; i < want_obj.nr; i++) {
527 o = want_obj.objects[i].item;
528 if (!is_our_ref(o))
529 die("git upload-pack: not our ref %s",
530 sha1_to_hex(o->sha1));
534 static void receive_needs(void)
536 struct object_array shallows = OBJECT_ARRAY_INIT;
537 int depth = 0;
538 int has_non_tip = 0;
540 shallow_nr = 0;
541 for (;;) {
542 struct object *o;
543 const char *features;
544 unsigned char sha1_buf[20];
545 char *line = packet_read_line(0, NULL);
546 reset_timeout();
547 if (!line)
548 break;
550 if (starts_with(line, "shallow ")) {
551 unsigned char sha1[20];
552 struct object *object;
553 if (get_sha1_hex(line + 8, sha1))
554 die("invalid shallow line: %s", line);
555 object = parse_object(sha1);
556 if (!object)
557 continue;
558 if (object->type != OBJ_COMMIT)
559 die("invalid shallow object %s", sha1_to_hex(sha1));
560 if (!(object->flags & CLIENT_SHALLOW)) {
561 object->flags |= CLIENT_SHALLOW;
562 add_object_array(object, NULL, &shallows);
564 continue;
566 if (starts_with(line, "deepen ")) {
567 char *end;
568 depth = strtol(line + 7, &end, 0);
569 if (end == line + 7 || depth <= 0)
570 die("Invalid deepen: %s", line);
571 continue;
573 if (!starts_with(line, "want ") ||
574 get_sha1_hex(line+5, sha1_buf))
575 die("git upload-pack: protocol error, "
576 "expected to get sha, not '%s'", line);
578 features = line + 45;
580 if (parse_feature_request(features, "multi_ack_detailed"))
581 multi_ack = 2;
582 else if (parse_feature_request(features, "multi_ack"))
583 multi_ack = 1;
584 if (parse_feature_request(features, "no-done"))
585 no_done = 1;
586 if (parse_feature_request(features, "thin-pack"))
587 use_thin_pack = 1;
588 if (parse_feature_request(features, "ofs-delta"))
589 use_ofs_delta = 1;
590 if (parse_feature_request(features, "side-band-64k"))
591 use_sideband = LARGE_PACKET_MAX;
592 else if (parse_feature_request(features, "side-band"))
593 use_sideband = DEFAULT_PACKET_MAX;
594 if (parse_feature_request(features, "no-progress"))
595 no_progress = 1;
596 if (parse_feature_request(features, "include-tag"))
597 use_include_tag = 1;
599 o = parse_object(sha1_buf);
600 if (!o)
601 die("git upload-pack: not our ref %s",
602 sha1_to_hex(sha1_buf));
603 if (!(o->flags & WANTED)) {
604 o->flags |= WANTED;
605 if (!is_our_ref(o))
606 has_non_tip = 1;
607 add_object_array(o, NULL, &want_obj);
612 * We have sent all our refs already, and the other end
613 * should have chosen out of them. When we are operating
614 * in the stateless RPC mode, however, their choice may
615 * have been based on the set of older refs advertised
616 * by another process that handled the initial request.
618 if (has_non_tip)
619 check_non_tip();
621 if (!use_sideband && daemon_mode)
622 no_progress = 1;
624 if (depth == 0 && shallows.nr == 0)
625 return;
626 if (depth > 0) {
627 struct commit_list *result = NULL, *backup = NULL;
628 int i;
629 if (depth == INFINITE_DEPTH && !is_repository_shallow())
630 for (i = 0; i < shallows.nr; i++) {
631 struct object *object = shallows.objects[i].item;
632 object->flags |= NOT_SHALLOW;
634 else
635 backup = result =
636 get_shallow_commits(&want_obj, depth,
637 SHALLOW, NOT_SHALLOW);
638 while (result) {
639 struct object *object = &result->item->object;
640 if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
641 packet_write(1, "shallow %s",
642 sha1_to_hex(object->sha1));
643 register_shallow(object->sha1);
644 shallow_nr++;
646 result = result->next;
648 free_commit_list(backup);
649 for (i = 0; i < shallows.nr; i++) {
650 struct object *object = shallows.objects[i].item;
651 if (object->flags & NOT_SHALLOW) {
652 struct commit_list *parents;
653 packet_write(1, "unshallow %s",
654 sha1_to_hex(object->sha1));
655 object->flags &= ~CLIENT_SHALLOW;
656 /* make sure the real parents are parsed */
657 unregister_shallow(object->sha1);
658 object->parsed = 0;
659 parse_commit_or_die((struct commit *)object);
660 parents = ((struct commit *)object)->parents;
661 while (parents) {
662 add_object_array(&parents->item->object,
663 NULL, &want_obj);
664 parents = parents->next;
666 add_object_array(object, NULL, &extra_edge_obj);
668 /* make sure commit traversal conforms to client */
669 register_shallow(object->sha1);
671 packet_flush(1);
672 } else
673 if (shallows.nr > 0) {
674 int i;
675 for (i = 0; i < shallows.nr; i++)
676 register_shallow(shallows.objects[i].item->sha1);
679 shallow_nr += shallows.nr;
680 free(shallows.objects);
683 /* return non-zero if the ref is hidden, otherwise 0 */
684 static int mark_our_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
686 struct object *o = lookup_unknown_object(sha1);
688 if (ref_is_hidden(refname)) {
689 o->flags |= HIDDEN_REF;
690 return 1;
692 if (!o)
693 die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
694 o->flags |= OUR_REF;
695 return 0;
698 static void format_symref_info(struct strbuf *buf, struct string_list *symref)
700 struct string_list_item *item;
702 if (!symref->nr)
703 return;
704 for_each_string_list_item(item, symref)
705 strbuf_addf(buf, " symref=%s:%s", item->string, (char *)item->util);
708 static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
710 static const char *capabilities = "multi_ack thin-pack side-band"
711 " side-band-64k ofs-delta shallow no-progress"
712 " include-tag multi_ack_detailed";
713 const char *refname_nons = strip_namespace(refname);
714 unsigned char peeled[20];
716 if (mark_our_ref(refname, sha1, flag, NULL))
717 return 0;
719 if (capabilities) {
720 struct strbuf symref_info = STRBUF_INIT;
722 format_symref_info(&symref_info, cb_data);
723 packet_write(1, "%s %s%c%s%s%s%s agent=%s\n",
724 sha1_to_hex(sha1), refname_nons,
725 0, capabilities,
726 allow_tip_sha1_in_want ? " allow-tip-sha1-in-want" : "",
727 stateless_rpc ? " no-done" : "",
728 symref_info.buf,
729 git_user_agent_sanitized());
730 strbuf_release(&symref_info);
731 } else {
732 packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname_nons);
734 capabilities = NULL;
735 if (!peel_ref(refname, peeled))
736 packet_write(1, "%s %s^{}\n", sha1_to_hex(peeled), refname_nons);
737 return 0;
740 static int find_symref(const char *refname, const unsigned char *sha1, int flag,
741 void *cb_data)
743 const char *symref_target;
744 struct string_list_item *item;
745 unsigned char unused[20];
747 if ((flag & REF_ISSYMREF) == 0)
748 return 0;
749 symref_target = resolve_ref_unsafe(refname, 0, unused, &flag);
750 if (!symref_target || (flag & REF_ISSYMREF) == 0)
751 die("'%s' is a symref but it is not?", refname);
752 item = string_list_append(cb_data, refname);
753 item->util = xstrdup(symref_target);
754 return 0;
757 static void upload_pack(void)
759 struct string_list symref = STRING_LIST_INIT_DUP;
761 head_ref_namespaced(find_symref, &symref);
763 if (advertise_refs || !stateless_rpc) {
764 reset_timeout();
765 head_ref_namespaced(send_ref, &symref);
766 for_each_namespaced_ref(send_ref, &symref);
767 advertise_shallow_grafts(1);
768 packet_flush(1);
769 } else {
770 head_ref_namespaced(mark_our_ref, NULL);
771 for_each_namespaced_ref(mark_our_ref, NULL);
773 string_list_clear(&symref, 1);
774 if (advertise_refs)
775 return;
777 receive_needs();
778 if (want_obj.nr) {
779 get_common_commits();
780 create_pack_file();
784 static int upload_pack_config(const char *var, const char *value, void *unused)
786 if (!strcmp("uploadpack.allowtipsha1inwant", var))
787 allow_tip_sha1_in_want = git_config_bool(var, value);
788 else if (!strcmp("uploadpack.keepalive", var)) {
789 keepalive = git_config_int(var, value);
790 if (!keepalive)
791 keepalive = -1;
793 return parse_hide_refs_config(var, value, "uploadpack");
796 int main(int argc, char **argv)
798 char *dir;
799 int i;
800 int strict = 0;
802 git_setup_gettext();
804 packet_trace_identity("upload-pack");
805 git_extract_argv0_path(argv[0]);
806 check_replace_refs = 0;
808 for (i = 1; i < argc; i++) {
809 char *arg = argv[i];
811 if (arg[0] != '-')
812 break;
813 if (!strcmp(arg, "--advertise-refs")) {
814 advertise_refs = 1;
815 continue;
817 if (!strcmp(arg, "--stateless-rpc")) {
818 stateless_rpc = 1;
819 continue;
821 if (!strcmp(arg, "--strict")) {
822 strict = 1;
823 continue;
825 if (starts_with(arg, "--timeout=")) {
826 timeout = atoi(arg+10);
827 daemon_mode = 1;
828 continue;
830 if (!strcmp(arg, "--")) {
831 i++;
832 break;
836 if (i != argc-1)
837 usage(upload_pack_usage);
839 setup_path();
841 dir = argv[i];
843 if (!enter_repo(dir, strict))
844 die("'%s' does not appear to be a git repository", dir);
846 git_config(upload_pack_config, NULL);
847 upload_pack();
848 return 0;