11 #include "list-objects.h"
12 #include "run-command.h"
16 #include "string-list.h"
17 #include "argv-array.h"
19 static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<n>] <dir>";
21 /* Remember to update object flag allocation in object.h */
22 #define THEY_HAVE (1u << 11)
23 #define OUR_REF (1u << 12)
24 #define WANTED (1u << 13)
25 #define COMMON_KNOWN (1u << 14)
26 #define REACHABLE (1u << 15)
28 #define SHALLOW (1u << 16)
29 #define NOT_SHALLOW (1u << 17)
30 #define CLIENT_SHALLOW (1u << 18)
31 #define HIDDEN_REF (1u << 19)
33 static unsigned long oldest_have;
35 static int deepen_relative;
38 static int use_thin_pack, use_ofs_delta, use_include_tag;
39 static int no_progress, daemon_mode;
40 /* Allow specifying sha1 if it is a ref tip. */
41 #define ALLOW_TIP_SHA1 01
42 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
43 #define ALLOW_REACHABLE_SHA1 02
44 static unsigned int allow_unadvertised_object_request;
45 static int shallow_nr;
46 static struct object_array have_obj;
47 static struct object_array want_obj;
48 static struct object_array extra_edge_obj;
49 static unsigned int timeout;
50 static int keepalive = 5;
52 * otherwise maximum packet size (up to 65520 bytes).
54 static int use_sideband;
55 static int advertise_refs;
56 static int stateless_rpc;
58 static void reset_timeout(void)
63 static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
66 return send_sideband(1, fd, data, sz, use_sideband);
71 /* XXX: are we happy to lose stuff here? */
75 write_or_die(fd, data, sz);
79 static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
82 if (graft->nr_parent == -1)
83 fprintf(fp, "--shallow %s\n", oid_to_hex(&graft->oid));
87 static void create_pack_file(void)
89 struct child_process pack_objects = CHILD_PROCESS_INIT;
90 char data[8193], progress[128];
91 char abort_msg[] = "aborting due to possible repository "
92 "corruption on the remote side.";
100 argv[arg++] = "--shallow-file";
103 argv[arg++] = "pack-objects";
104 argv[arg++] = "--revs";
106 argv[arg++] = "--thin";
108 argv[arg++] = "--stdout";
110 argv[arg++] = "--shallow";
112 argv[arg++] = "--progress";
114 argv[arg++] = "--delta-base-offset";
116 argv[arg++] = "--include-tag";
119 pack_objects.in = -1;
120 pack_objects.out = -1;
121 pack_objects.err = -1;
122 pack_objects.git_cmd = 1;
123 pack_objects.argv = argv;
125 if (start_command(&pack_objects))
126 die("git upload-pack: unable to fork git-pack-objects");
128 pipe_fd = xfdopen(pack_objects.in, "w");
131 for_each_commit_graft(write_one_shallow, pipe_fd);
133 for (i = 0; i < want_obj.nr; i++)
134 fprintf(pipe_fd, "%s\n",
135 oid_to_hex(&want_obj.objects[i].item->oid));
136 fprintf(pipe_fd, "--not\n");
137 for (i = 0; i < have_obj.nr; i++)
138 fprintf(pipe_fd, "%s\n",
139 oid_to_hex(&have_obj.objects[i].item->oid));
140 for (i = 0; i < extra_edge_obj.nr; i++)
141 fprintf(pipe_fd, "%s\n",
142 oid_to_hex(&extra_edge_obj.objects[i].item->oid));
143 fprintf(pipe_fd, "\n");
147 /* We read from pack_objects.err to capture stderr output for
148 * progress bar, and pack_objects.out to capture the pack data.
152 struct pollfd pfd[2];
153 int pe, pu, pollsize;
161 if (0 <= pack_objects.out) {
162 pfd[pollsize].fd = pack_objects.out;
163 pfd[pollsize].events = POLLIN;
167 if (0 <= pack_objects.err) {
168 pfd[pollsize].fd = pack_objects.err;
169 pfd[pollsize].events = POLLIN;
177 ret = poll(pfd, pollsize,
178 keepalive < 0 ? -1 : 1000 * keepalive);
181 if (errno != EINTR) {
182 error("poll failed, resuming: %s",
188 if (0 <= pe && (pfd[pe].revents & (POLLIN|POLLHUP))) {
189 /* Status ready; we ship that in the side-band
190 * or dump to the standard error.
192 sz = xread(pack_objects.err, progress,
195 send_client_data(2, progress, sz);
197 close(pack_objects.err);
198 pack_objects.err = -1;
202 /* give priority to status messages */
205 if (0 <= pu && (pfd[pu].revents & (POLLIN|POLLHUP))) {
206 /* Data ready; we keep the last byte to ourselves
207 * in case we detect broken rev-list, so that we
208 * can leave the stream corrupted. This is
209 * unfortunate -- unpack-objects would happily
210 * accept a valid packdata with trailing garbage,
211 * so appending garbage after we pass all the
212 * pack data is not good enough to signal
213 * breakage to downstream.
221 sz = xread(pack_objects.out, cp,
222 sizeof(data) - outsz);
226 close(pack_objects.out);
227 pack_objects.out = -1;
233 buffered = data[sz-1] & 0xFF;
238 sz = send_client_data(1, data, sz);
244 * We hit the keepalive timeout without saying anything; send
245 * an empty message on the data sideband just to let the other
246 * side know we're still working on it, but don't have any data
249 * If we don't have a sideband channel, there's no room in the
250 * protocol to say anything, so those clients are just out of
253 if (!ret && use_sideband) {
254 static const char buf[] = "0005\1";
255 write_or_die(1, buf, 5);
259 if (finish_command(&pack_objects)) {
260 error("git upload-pack: git-pack-objects died with error.");
267 sz = send_client_data(1, data, 1);
270 fprintf(stderr, "flushed.\n");
277 send_client_data(3, abort_msg, sizeof(abort_msg));
278 die("git upload-pack: %s", abort_msg);
281 static int got_sha1(const char *hex, unsigned char *sha1)
284 int we_knew_they_have = 0;
286 if (get_sha1_hex(hex, sha1))
287 die("git upload-pack: expected SHA1 object, got '%s'", hex);
288 if (!has_sha1_file(sha1))
291 o = parse_object(sha1);
293 die("oops (%s)", sha1_to_hex(sha1));
294 if (o->type == OBJ_COMMIT) {
295 struct commit_list *parents;
296 struct commit *commit = (struct commit *)o;
297 if (o->flags & THEY_HAVE)
298 we_knew_they_have = 1;
300 o->flags |= THEY_HAVE;
301 if (!oldest_have || (commit->date < oldest_have))
302 oldest_have = commit->date;
303 for (parents = commit->parents;
305 parents = parents->next)
306 parents->item->object.flags |= THEY_HAVE;
308 if (!we_knew_they_have) {
309 add_object_array(o, NULL, &have_obj);
315 static int reachable(struct commit *want)
317 struct commit_list *work = NULL;
319 commit_list_insert_by_date(want, &work);
321 struct commit_list *list;
322 struct commit *commit = pop_commit(&work);
324 if (commit->object.flags & THEY_HAVE) {
325 want->object.flags |= COMMON_KNOWN;
328 if (!commit->object.parsed)
329 parse_object(commit->object.oid.hash);
330 if (commit->object.flags & REACHABLE)
332 commit->object.flags |= REACHABLE;
333 if (commit->date < oldest_have)
335 for (list = commit->parents; list; list = list->next) {
336 struct commit *parent = list->item;
337 if (!(parent->object.flags & REACHABLE))
338 commit_list_insert_by_date(parent, &work);
341 want->object.flags |= REACHABLE;
342 clear_commit_marks(want, REACHABLE);
343 free_commit_list(work);
344 return (want->object.flags & COMMON_KNOWN);
347 static int ok_to_give_up(void)
354 for (i = 0; i < want_obj.nr; i++) {
355 struct object *want = want_obj.objects[i].item;
357 if (want->flags & COMMON_KNOWN)
359 want = deref_tag(want, "a want line", 0);
360 if (!want || want->type != OBJ_COMMIT) {
361 /* no way to tell if this is reachable by
362 * looking at the ancestry chain alone, so
363 * leave a note to ourselves not to worry about
364 * this object anymore.
366 want_obj.objects[i].item->flags |= COMMON_KNOWN;
369 if (!reachable((struct commit *)want))
375 static int get_common_commits(void)
377 unsigned char sha1[20];
383 save_commit_buffer = 0;
386 char *line = packet_read_line(0, NULL);
392 if (multi_ack == 2 && got_common
393 && !got_other && ok_to_give_up()) {
395 packet_write(1, "ACK %s ready\n", last_hex);
397 if (have_obj.nr == 0 || multi_ack)
398 packet_write(1, "NAK\n");
400 if (no_done && sent_ready) {
401 packet_write(1, "ACK %s\n", last_hex);
410 if (skip_prefix(line, "have ", &arg)) {
411 switch (got_sha1(arg, sha1)) {
412 case -1: /* they have what we do not */
414 if (multi_ack && ok_to_give_up()) {
415 const char *hex = sha1_to_hex(sha1);
416 if (multi_ack == 2) {
418 packet_write(1, "ACK %s ready\n", hex);
420 packet_write(1, "ACK %s continue\n", hex);
425 memcpy(last_hex, sha1_to_hex(sha1), 41);
427 packet_write(1, "ACK %s common\n", last_hex);
429 packet_write(1, "ACK %s continue\n", last_hex);
430 else if (have_obj.nr == 1)
431 packet_write(1, "ACK %s\n", last_hex);
436 if (!strcmp(line, "done")) {
437 if (have_obj.nr > 0) {
439 packet_write(1, "ACK %s\n", last_hex);
442 packet_write(1, "NAK\n");
445 die("git upload-pack: expected SHA1 list, got '%s'", line);
449 static int is_our_ref(struct object *o)
451 int allow_hidden_ref = (allow_unadvertised_object_request &
452 (ALLOW_TIP_SHA1 | ALLOW_REACHABLE_SHA1));
453 return o->flags & ((allow_hidden_ref ? HIDDEN_REF : 0) | OUR_REF);
457 * on successful case, it's up to the caller to close cmd->out
459 static int do_reachable_revlist(struct child_process *cmd,
460 struct object_array *src,
461 struct object_array *reachable)
463 static const char *argv[] = {
464 "rev-list", "--stdin", NULL,
467 char namebuf[42]; /* ^ + SHA-1 + LF */
477 * If the next rev-list --stdin encounters an unknown commit,
478 * it terminates, which will cause SIGPIPE in the write loop
481 sigchain_push(SIGPIPE, SIG_IGN);
483 if (start_command(cmd))
488 for (i = get_max_object_index(); 0 < i; ) {
489 o = get_indexed_object(--i);
492 if (reachable && o->type == OBJ_COMMIT)
493 o->flags &= ~TMP_MARK;
496 memcpy(namebuf + 1, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
497 if (write_in_full(cmd->in, namebuf, 42) < 0)
501 for (i = 0; i < src->nr; i++) {
502 o = src->objects[i].item;
505 add_object_array(o, NULL, reachable);
508 if (reachable && o->type == OBJ_COMMIT)
509 o->flags |= TMP_MARK;
510 memcpy(namebuf, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
511 if (write_in_full(cmd->in, namebuf, 41) < 0)
516 sigchain_pop(SIGPIPE);
521 sigchain_pop(SIGPIPE);
530 static int get_reachable_list(struct object_array *src,
531 struct object_array *reachable)
533 struct child_process cmd = CHILD_PROCESS_INIT;
536 char namebuf[42]; /* ^ + SHA-1 + LF */
538 if (do_reachable_revlist(&cmd, src, reachable) < 0)
541 while ((i = read_in_full(cmd.out, namebuf, 41)) == 41) {
542 struct object_id sha1;
544 if (namebuf[40] != '\n' || get_oid_hex(namebuf, &sha1))
547 o = lookup_object(sha1.hash);
548 if (o && o->type == OBJ_COMMIT) {
549 o->flags &= ~TMP_MARK;
552 for (i = get_max_object_index(); 0 < i; i--) {
553 o = get_indexed_object(i - 1);
554 if (o && o->type == OBJ_COMMIT &&
555 (o->flags & TMP_MARK)) {
556 add_object_array(o, NULL, reachable);
557 o->flags &= ~TMP_MARK;
562 if (finish_command(&cmd))
568 static int has_unreachable(struct object_array *src)
570 struct child_process cmd = CHILD_PROCESS_INIT;
574 if (do_reachable_revlist(&cmd, src, NULL) < 0)
578 * The commits out of the rev-list are not ancestors of
581 i = read_in_full(cmd.out, buf, 1);
588 * rev-list may have died by encountering a bad commit
589 * in the history, in which case we do want to bail out
590 * even when it showed no commit.
592 if (finish_command(&cmd))
595 /* All the non-tip ones are ancestors of what we advertised */
599 sigchain_pop(SIGPIPE);
605 static void check_non_tip(void)
610 * In the normal in-process case without
611 * uploadpack.allowReachableSHA1InWant,
612 * non-tip requests can never happen.
614 if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1))
616 if (!has_unreachable(&want_obj))
617 /* All the non-tip ones are ancestors of what we advertised */
621 /* Pick one of them (we know there at least is one) */
622 for (i = 0; i < want_obj.nr; i++) {
623 struct object *o = want_obj.objects[i].item;
625 die("git upload-pack: not our ref %s",
626 oid_to_hex(&o->oid));
630 static void send_shallow(struct commit_list *result)
633 struct object *object = &result->item->object;
634 if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
635 packet_write(1, "shallow %s",
636 oid_to_hex(&object->oid));
637 register_shallow(object->oid.hash);
640 result = result->next;
644 static void send_unshallow(const struct object_array *shallows)
648 for (i = 0; i < shallows->nr; i++) {
649 struct object *object = shallows->objects[i].item;
650 if (object->flags & NOT_SHALLOW) {
651 struct commit_list *parents;
652 packet_write(1, "unshallow %s",
653 oid_to_hex(&object->oid));
654 object->flags &= ~CLIENT_SHALLOW;
656 * We want to _register_ "object" as shallow, but we
657 * also need to traverse object's parents to deepen a
658 * shallow clone. Unregister it for now so we can
659 * parse and add the parents to the want list, then
662 unregister_shallow(object->oid.hash);
664 parse_commit_or_die((struct commit *)object);
665 parents = ((struct commit *)object)->parents;
667 add_object_array(&parents->item->object,
669 parents = parents->next;
671 add_object_array(object, NULL, &extra_edge_obj);
673 /* make sure commit traversal conforms to client */
674 register_shallow(object->oid.hash);
678 static void deepen(int depth, int deepen_relative,
679 struct object_array *shallows)
681 if (depth == INFINITE_DEPTH && !is_repository_shallow()) {
684 for (i = 0; i < shallows->nr; i++) {
685 struct object *object = shallows->objects[i].item;
686 object->flags |= NOT_SHALLOW;
688 } else if (deepen_relative) {
689 struct object_array reachable_shallows = OBJECT_ARRAY_INIT;
690 struct commit_list *result;
692 get_reachable_list(shallows, &reachable_shallows);
693 result = get_shallow_commits(&reachable_shallows,
695 SHALLOW, NOT_SHALLOW);
696 send_shallow(result);
697 free_commit_list(result);
698 object_array_clear(&reachable_shallows);
700 struct commit_list *result;
702 result = get_shallow_commits(&want_obj, depth,
703 SHALLOW, NOT_SHALLOW);
704 send_shallow(result);
705 free_commit_list(result);
708 send_unshallow(shallows);
712 static void deepen_by_rev_list(int ac, const char **av,
713 struct object_array *shallows)
715 struct commit_list *result;
717 result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
718 send_shallow(result);
719 free_commit_list(result);
720 send_unshallow(shallows);
724 static void receive_needs(void)
726 struct object_array shallows = OBJECT_ARRAY_INIT;
727 struct string_list deepen_not = STRING_LIST_INIT_DUP;
730 unsigned long deepen_since = 0;
731 int deepen_rev_list = 0;
736 const char *features;
737 unsigned char sha1_buf[20];
738 char *line = packet_read_line(0, NULL);
745 if (skip_prefix(line, "shallow ", &arg)) {
746 unsigned char sha1[20];
747 struct object *object;
748 if (get_sha1_hex(arg, sha1))
749 die("invalid shallow line: %s", line);
750 object = parse_object(sha1);
753 if (object->type != OBJ_COMMIT)
754 die("invalid shallow object %s", sha1_to_hex(sha1));
755 if (!(object->flags & CLIENT_SHALLOW)) {
756 object->flags |= CLIENT_SHALLOW;
757 add_object_array(object, NULL, &shallows);
761 if (skip_prefix(line, "deepen ", &arg)) {
763 depth = strtol(arg, &end, 0);
764 if (!end || *end || depth <= 0)
765 die("Invalid deepen: %s", line);
768 if (skip_prefix(line, "deepen-since ", &arg)) {
770 deepen_since = strtoul(arg, &end, 0);
771 if (!end || *end || !deepen_since ||
772 /* revisions.c's max_age -1 is special */
774 die("Invalid deepen-since: %s", line);
778 if (skip_prefix(line, "deepen-not ", &arg)) {
780 unsigned char sha1[20];
781 if (expand_ref(arg, strlen(arg), sha1, &ref) != 1)
782 die("git upload-pack: ambiguous deepen-not: %s", line);
783 string_list_append(&deepen_not, ref);
788 if (!skip_prefix(line, "want ", &arg) ||
789 get_sha1_hex(arg, sha1_buf))
790 die("git upload-pack: protocol error, "
791 "expected to get sha, not '%s'", line);
795 if (parse_feature_request(features, "deepen-relative"))
797 if (parse_feature_request(features, "multi_ack_detailed"))
799 else if (parse_feature_request(features, "multi_ack"))
801 if (parse_feature_request(features, "no-done"))
803 if (parse_feature_request(features, "thin-pack"))
805 if (parse_feature_request(features, "ofs-delta"))
807 if (parse_feature_request(features, "side-band-64k"))
808 use_sideband = LARGE_PACKET_MAX;
809 else if (parse_feature_request(features, "side-band"))
810 use_sideband = DEFAULT_PACKET_MAX;
811 if (parse_feature_request(features, "no-progress"))
813 if (parse_feature_request(features, "include-tag"))
816 o = parse_object(sha1_buf);
818 die("git upload-pack: not our ref %s",
819 sha1_to_hex(sha1_buf));
820 if (!(o->flags & WANTED)) {
824 add_object_array(o, NULL, &want_obj);
829 * We have sent all our refs already, and the other end
830 * should have chosen out of them. When we are operating
831 * in the stateless RPC mode, however, their choice may
832 * have been based on the set of older refs advertised
833 * by another process that handled the initial request.
838 if (!use_sideband && daemon_mode)
841 if (depth == 0 && !deepen_rev_list && shallows.nr == 0)
843 if (depth > 0 && deepen_rev_list)
844 die("git upload-pack: deepen and deepen-since (or deepen-not) cannot be used together");
846 deepen(depth, deepen_relative, &shallows);
847 else if (deepen_rev_list) {
848 struct argv_array av = ARGV_ARRAY_INIT;
851 argv_array_push(&av, "rev-list");
853 argv_array_pushf(&av, "--max-age=%lu", deepen_since);
855 argv_array_push(&av, "--not");
856 for (i = 0; i < deepen_not.nr; i++) {
857 struct string_list_item *s = deepen_not.items + i;
858 argv_array_push(&av, s->string);
860 argv_array_push(&av, "--not");
862 for (i = 0; i < want_obj.nr; i++) {
863 struct object *o = want_obj.objects[i].item;
864 argv_array_push(&av, oid_to_hex(&o->oid));
866 deepen_by_rev_list(av.argc, av.argv, &shallows);
867 argv_array_clear(&av);
870 if (shallows.nr > 0) {
872 for (i = 0; i < shallows.nr; i++)
873 register_shallow(shallows.objects[i].item->oid.hash);
876 shallow_nr += shallows.nr;
877 free(shallows.objects);
880 /* return non-zero if the ref is hidden, otherwise 0 */
881 static int mark_our_ref(const char *refname, const char *refname_full,
882 const struct object_id *oid)
884 struct object *o = lookup_unknown_object(oid->hash);
886 if (ref_is_hidden(refname, refname_full)) {
887 o->flags |= HIDDEN_REF;
894 static int check_ref(const char *refname_full, const struct object_id *oid,
895 int flag, void *cb_data)
897 const char *refname = strip_namespace(refname_full);
899 mark_our_ref(refname, refname_full, oid);
903 static void format_symref_info(struct strbuf *buf, struct string_list *symref)
905 struct string_list_item *item;
909 for_each_string_list_item(item, symref)
910 strbuf_addf(buf, " symref=%s:%s", item->string, (char *)item->util);
913 static int send_ref(const char *refname, const struct object_id *oid,
914 int flag, void *cb_data)
916 static const char *capabilities = "multi_ack thin-pack side-band"
917 " side-band-64k ofs-delta shallow deepen-since deepen-not"
918 " deepen-relative no-progress include-tag multi_ack_detailed";
919 const char *refname_nons = strip_namespace(refname);
920 struct object_id peeled;
922 if (mark_our_ref(refname_nons, refname, oid))
926 struct strbuf symref_info = STRBUF_INIT;
928 format_symref_info(&symref_info, cb_data);
929 packet_write(1, "%s %s%c%s%s%s%s%s agent=%s\n",
930 oid_to_hex(oid), refname_nons,
932 (allow_unadvertised_object_request & ALLOW_TIP_SHA1) ?
933 " allow-tip-sha1-in-want" : "",
934 (allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1) ?
935 " allow-reachable-sha1-in-want" : "",
936 stateless_rpc ? " no-done" : "",
938 git_user_agent_sanitized());
939 strbuf_release(&symref_info);
941 packet_write(1, "%s %s\n", oid_to_hex(oid), refname_nons);
944 if (!peel_ref(refname, peeled.hash))
945 packet_write(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons);
949 static int find_symref(const char *refname, const struct object_id *oid,
950 int flag, void *cb_data)
952 const char *symref_target;
953 struct string_list_item *item;
954 struct object_id unused;
956 if ((flag & REF_ISSYMREF) == 0)
958 symref_target = resolve_ref_unsafe(refname, 0, unused.hash, &flag);
959 if (!symref_target || (flag & REF_ISSYMREF) == 0)
960 die("'%s' is a symref but it is not?", refname);
961 item = string_list_append(cb_data, refname);
962 item->util = xstrdup(symref_target);
966 static void upload_pack(void)
968 struct string_list symref = STRING_LIST_INIT_DUP;
970 head_ref_namespaced(find_symref, &symref);
972 if (advertise_refs || !stateless_rpc) {
974 head_ref_namespaced(send_ref, &symref);
975 for_each_namespaced_ref(send_ref, &symref);
976 advertise_shallow_grafts(1);
979 head_ref_namespaced(check_ref, NULL);
980 for_each_namespaced_ref(check_ref, NULL);
982 string_list_clear(&symref, 1);
988 get_common_commits();
993 static int upload_pack_config(const char *var, const char *value, void *unused)
995 if (!strcmp("uploadpack.allowtipsha1inwant", var)) {
996 if (git_config_bool(var, value))
997 allow_unadvertised_object_request |= ALLOW_TIP_SHA1;
999 allow_unadvertised_object_request &= ~ALLOW_TIP_SHA1;
1000 } else if (!strcmp("uploadpack.allowreachablesha1inwant", var)) {
1001 if (git_config_bool(var, value))
1002 allow_unadvertised_object_request |= ALLOW_REACHABLE_SHA1;
1004 allow_unadvertised_object_request &= ~ALLOW_REACHABLE_SHA1;
1005 } else if (!strcmp("uploadpack.keepalive", var)) {
1006 keepalive = git_config_int(var, value);
1010 return parse_hide_refs_config(var, value, "uploadpack");
1013 int main(int argc, char **argv)
1019 git_setup_gettext();
1021 packet_trace_identity("upload-pack");
1022 git_extract_argv0_path(argv[0]);
1023 check_replace_refs = 0;
1025 for (i = 1; i < argc; i++) {
1026 const char *arg = argv[i];
1030 if (!strcmp(arg, "--advertise-refs")) {
1034 if (!strcmp(arg, "--stateless-rpc")) {
1038 if (!strcmp(arg, "--strict")) {
1042 if (skip_prefix(arg, "--timeout=", &arg)) {
1043 timeout = atoi(arg);
1047 if (!strcmp(arg, "--")) {
1054 usage(upload_pack_usage);
1060 if (!enter_repo(dir, strict))
1061 die("'%s' does not appear to be a git repository", dir);
1063 git_config(upload_pack_config, NULL);