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
;
37 static int use_thin_pack
, use_ofs_delta
, use_include_tag
;
38 static int no_progress
, daemon_mode
;
39 /* Allow specifying sha1 if it is a ref tip. */
40 #define ALLOW_TIP_SHA1 01
41 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
42 #define ALLOW_REACHABLE_SHA1 02
43 static unsigned int allow_unadvertised_object_request
;
44 static int shallow_nr
;
45 static struct object_array have_obj
;
46 static struct object_array want_obj
;
47 static struct object_array extra_edge_obj
;
48 static unsigned int timeout
;
49 static int keepalive
= 5;
51 * otherwise maximum packet size (up to 65520 bytes).
53 static int use_sideband
;
54 static int advertise_refs
;
55 static int stateless_rpc
;
57 static void reset_timeout(void)
62 static ssize_t
send_client_data(int fd
, const char *data
, ssize_t sz
)
65 return send_sideband(1, fd
, data
, sz
, use_sideband
);
70 /* XXX: are we happy to lose stuff here? */
74 write_or_die(fd
, data
, sz
);
78 static int write_one_shallow(const struct commit_graft
*graft
, void *cb_data
)
81 if (graft
->nr_parent
== -1)
82 fprintf(fp
, "--shallow %s\n", oid_to_hex(&graft
->oid
));
86 static void create_pack_file(void)
88 struct child_process pack_objects
= CHILD_PROCESS_INIT
;
89 char data
[8193], progress
[128];
90 char abort_msg
[] = "aborting due to possible repository "
91 "corruption on the remote side.";
99 argv
[arg
++] = "--shallow-file";
102 argv
[arg
++] = "pack-objects";
103 argv
[arg
++] = "--revs";
105 argv
[arg
++] = "--thin";
107 argv
[arg
++] = "--stdout";
109 argv
[arg
++] = "--shallow";
111 argv
[arg
++] = "--progress";
113 argv
[arg
++] = "--delta-base-offset";
115 argv
[arg
++] = "--include-tag";
118 pack_objects
.in
= -1;
119 pack_objects
.out
= -1;
120 pack_objects
.err
= -1;
121 pack_objects
.git_cmd
= 1;
122 pack_objects
.argv
= argv
;
124 if (start_command(&pack_objects
))
125 die("git upload-pack: unable to fork git-pack-objects");
127 pipe_fd
= xfdopen(pack_objects
.in
, "w");
130 for_each_commit_graft(write_one_shallow
, pipe_fd
);
132 for (i
= 0; i
< want_obj
.nr
; i
++)
133 fprintf(pipe_fd
, "%s\n",
134 oid_to_hex(&want_obj
.objects
[i
].item
->oid
));
135 fprintf(pipe_fd
, "--not\n");
136 for (i
= 0; i
< have_obj
.nr
; i
++)
137 fprintf(pipe_fd
, "%s\n",
138 oid_to_hex(&have_obj
.objects
[i
].item
->oid
));
139 for (i
= 0; i
< extra_edge_obj
.nr
; i
++)
140 fprintf(pipe_fd
, "%s\n",
141 oid_to_hex(&extra_edge_obj
.objects
[i
].item
->oid
));
142 fprintf(pipe_fd
, "\n");
146 /* We read from pack_objects.err to capture stderr output for
147 * progress bar, and pack_objects.out to capture the pack data.
151 struct pollfd pfd
[2];
152 int pe
, pu
, pollsize
;
160 if (0 <= pack_objects
.out
) {
161 pfd
[pollsize
].fd
= pack_objects
.out
;
162 pfd
[pollsize
].events
= POLLIN
;
166 if (0 <= pack_objects
.err
) {
167 pfd
[pollsize
].fd
= pack_objects
.err
;
168 pfd
[pollsize
].events
= POLLIN
;
176 ret
= poll(pfd
, pollsize
,
177 keepalive
< 0 ? -1 : 1000 * keepalive
);
180 if (errno
!= EINTR
) {
181 error("poll failed, resuming: %s",
187 if (0 <= pe
&& (pfd
[pe
].revents
& (POLLIN
|POLLHUP
))) {
188 /* Status ready; we ship that in the side-band
189 * or dump to the standard error.
191 sz
= xread(pack_objects
.err
, progress
,
194 send_client_data(2, progress
, sz
);
196 close(pack_objects
.err
);
197 pack_objects
.err
= -1;
201 /* give priority to status messages */
204 if (0 <= pu
&& (pfd
[pu
].revents
& (POLLIN
|POLLHUP
))) {
205 /* Data ready; we keep the last byte to ourselves
206 * in case we detect broken rev-list, so that we
207 * can leave the stream corrupted. This is
208 * unfortunate -- unpack-objects would happily
209 * accept a valid packdata with trailing garbage,
210 * so appending garbage after we pass all the
211 * pack data is not good enough to signal
212 * breakage to downstream.
220 sz
= xread(pack_objects
.out
, cp
,
221 sizeof(data
) - outsz
);
225 close(pack_objects
.out
);
226 pack_objects
.out
= -1;
232 buffered
= data
[sz
-1] & 0xFF;
237 sz
= send_client_data(1, data
, sz
);
243 * We hit the keepalive timeout without saying anything; send
244 * an empty message on the data sideband just to let the other
245 * side know we're still working on it, but don't have any data
248 * If we don't have a sideband channel, there's no room in the
249 * protocol to say anything, so those clients are just out of
252 if (!ret
&& use_sideband
) {
253 static const char buf
[] = "0005\1";
254 write_or_die(1, buf
, 5);
258 if (finish_command(&pack_objects
)) {
259 error("git upload-pack: git-pack-objects died with error.");
266 sz
= send_client_data(1, data
, 1);
269 fprintf(stderr
, "flushed.\n");
276 send_client_data(3, abort_msg
, sizeof(abort_msg
));
277 die("git upload-pack: %s", abort_msg
);
280 static int got_sha1(const char *hex
, unsigned char *sha1
)
283 int we_knew_they_have
= 0;
285 if (get_sha1_hex(hex
, sha1
))
286 die("git upload-pack: expected SHA1 object, got '%s'", hex
);
287 if (!has_sha1_file(sha1
))
290 o
= parse_object(sha1
);
292 die("oops (%s)", sha1_to_hex(sha1
));
293 if (o
->type
== OBJ_COMMIT
) {
294 struct commit_list
*parents
;
295 struct commit
*commit
= (struct commit
*)o
;
296 if (o
->flags
& THEY_HAVE
)
297 we_knew_they_have
= 1;
299 o
->flags
|= THEY_HAVE
;
300 if (!oldest_have
|| (commit
->date
< oldest_have
))
301 oldest_have
= commit
->date
;
302 for (parents
= commit
->parents
;
304 parents
= parents
->next
)
305 parents
->item
->object
.flags
|= THEY_HAVE
;
307 if (!we_knew_they_have
) {
308 add_object_array(o
, NULL
, &have_obj
);
314 static int reachable(struct commit
*want
)
316 struct commit_list
*work
= NULL
;
318 commit_list_insert_by_date(want
, &work
);
320 struct commit_list
*list
;
321 struct commit
*commit
= pop_commit(&work
);
323 if (commit
->object
.flags
& THEY_HAVE
) {
324 want
->object
.flags
|= COMMON_KNOWN
;
327 if (!commit
->object
.parsed
)
328 parse_object(commit
->object
.oid
.hash
);
329 if (commit
->object
.flags
& REACHABLE
)
331 commit
->object
.flags
|= REACHABLE
;
332 if (commit
->date
< oldest_have
)
334 for (list
= commit
->parents
; list
; list
= list
->next
) {
335 struct commit
*parent
= list
->item
;
336 if (!(parent
->object
.flags
& REACHABLE
))
337 commit_list_insert_by_date(parent
, &work
);
340 want
->object
.flags
|= REACHABLE
;
341 clear_commit_marks(want
, REACHABLE
);
342 free_commit_list(work
);
343 return (want
->object
.flags
& COMMON_KNOWN
);
346 static int ok_to_give_up(void)
353 for (i
= 0; i
< want_obj
.nr
; i
++) {
354 struct object
*want
= want_obj
.objects
[i
].item
;
356 if (want
->flags
& COMMON_KNOWN
)
358 want
= deref_tag(want
, "a want line", 0);
359 if (!want
|| want
->type
!= OBJ_COMMIT
) {
360 /* no way to tell if this is reachable by
361 * looking at the ancestry chain alone, so
362 * leave a note to ourselves not to worry about
363 * this object anymore.
365 want_obj
.objects
[i
].item
->flags
|= COMMON_KNOWN
;
368 if (!reachable((struct commit
*)want
))
374 static int get_common_commits(void)
376 unsigned char sha1
[20];
382 save_commit_buffer
= 0;
385 char *line
= packet_read_line(0, NULL
);
391 if (multi_ack
== 2 && got_common
392 && !got_other
&& ok_to_give_up()) {
394 packet_write(1, "ACK %s ready\n", last_hex
);
396 if (have_obj
.nr
== 0 || multi_ack
)
397 packet_write(1, "NAK\n");
399 if (no_done
&& sent_ready
) {
400 packet_write(1, "ACK %s\n", last_hex
);
409 if (skip_prefix(line
, "have ", &arg
)) {
410 switch (got_sha1(arg
, sha1
)) {
411 case -1: /* they have what we do not */
413 if (multi_ack
&& ok_to_give_up()) {
414 const char *hex
= sha1_to_hex(sha1
);
415 if (multi_ack
== 2) {
417 packet_write(1, "ACK %s ready\n", hex
);
419 packet_write(1, "ACK %s continue\n", hex
);
424 memcpy(last_hex
, sha1_to_hex(sha1
), 41);
426 packet_write(1, "ACK %s common\n", last_hex
);
428 packet_write(1, "ACK %s continue\n", last_hex
);
429 else if (have_obj
.nr
== 1)
430 packet_write(1, "ACK %s\n", last_hex
);
435 if (!strcmp(line
, "done")) {
436 if (have_obj
.nr
> 0) {
438 packet_write(1, "ACK %s\n", last_hex
);
441 packet_write(1, "NAK\n");
444 die("git upload-pack: expected SHA1 list, got '%s'", line
);
448 static int is_our_ref(struct object
*o
)
450 int allow_hidden_ref
= (allow_unadvertised_object_request
&
451 (ALLOW_TIP_SHA1
| ALLOW_REACHABLE_SHA1
));
452 return o
->flags
& ((allow_hidden_ref
? HIDDEN_REF
: 0) | OUR_REF
);
455 static int has_unreachable(struct object_array
*src
)
457 static const char *argv
[] = {
458 "rev-list", "--stdin", NULL
,
460 static struct child_process cmd
= CHILD_PROCESS_INIT
;
462 char namebuf
[42]; /* ^ + SHA-1 + LF */
472 * If the next rev-list --stdin encounters an unknown commit,
473 * it terminates, which will cause SIGPIPE in the write loop
476 sigchain_push(SIGPIPE
, SIG_IGN
);
478 if (start_command(&cmd
))
483 for (i
= get_max_object_index(); 0 < i
; ) {
484 o
= get_indexed_object(--i
);
489 memcpy(namebuf
+ 1, oid_to_hex(&o
->oid
), GIT_SHA1_HEXSZ
);
490 if (write_in_full(cmd
.in
, namebuf
, 42) < 0)
494 for (i
= 0; i
< src
->nr
; i
++) {
495 o
= src
->objects
[i
].item
;
498 memcpy(namebuf
, oid_to_hex(&o
->oid
), GIT_SHA1_HEXSZ
);
499 if (write_in_full(cmd
.in
, namebuf
, 41) < 0)
506 * The commits out of the rev-list are not ancestors of
509 i
= read_in_full(cmd
.out
, namebuf
, 1);
516 * rev-list may have died by encountering a bad commit
517 * in the history, in which case we do want to bail out
518 * even when it showed no commit.
520 if (finish_command(&cmd
))
523 sigchain_pop(SIGPIPE
);
525 /* All the non-tip ones are ancestors of what we advertised */
529 sigchain_pop(SIGPIPE
);
538 static void check_non_tip(void)
543 * In the normal in-process case without
544 * uploadpack.allowReachableSHA1InWant,
545 * non-tip requests can never happen.
547 if (!stateless_rpc
&& !(allow_unadvertised_object_request
& ALLOW_REACHABLE_SHA1
))
549 if (!has_unreachable(&want_obj
))
550 /* All the non-tip ones are ancestors of what we advertised */
554 /* Pick one of them (we know there at least is one) */
555 for (i
= 0; i
< want_obj
.nr
; i
++) {
556 struct object
*o
= want_obj
.objects
[i
].item
;
558 die("git upload-pack: not our ref %s",
559 oid_to_hex(&o
->oid
));
563 static void send_shallow(struct commit_list
*result
)
566 struct object
*object
= &result
->item
->object
;
567 if (!(object
->flags
& (CLIENT_SHALLOW
|NOT_SHALLOW
))) {
568 packet_write(1, "shallow %s",
569 oid_to_hex(&object
->oid
));
570 register_shallow(object
->oid
.hash
);
573 result
= result
->next
;
577 static void send_unshallow(const struct object_array
*shallows
)
581 for (i
= 0; i
< shallows
->nr
; i
++) {
582 struct object
*object
= shallows
->objects
[i
].item
;
583 if (object
->flags
& NOT_SHALLOW
) {
584 struct commit_list
*parents
;
585 packet_write(1, "unshallow %s",
586 oid_to_hex(&object
->oid
));
587 object
->flags
&= ~CLIENT_SHALLOW
;
589 * We want to _register_ "object" as shallow, but we
590 * also need to traverse object's parents to deepen a
591 * shallow clone. Unregister it for now so we can
592 * parse and add the parents to the want list, then
595 unregister_shallow(object
->oid
.hash
);
597 parse_commit_or_die((struct commit
*)object
);
598 parents
= ((struct commit
*)object
)->parents
;
600 add_object_array(&parents
->item
->object
,
602 parents
= parents
->next
;
604 add_object_array(object
, NULL
, &extra_edge_obj
);
606 /* make sure commit traversal conforms to client */
607 register_shallow(object
->oid
.hash
);
611 static void deepen(int depth
, const struct object_array
*shallows
)
613 if (depth
== INFINITE_DEPTH
&& !is_repository_shallow()) {
616 for (i
= 0; i
< shallows
->nr
; i
++) {
617 struct object
*object
= shallows
->objects
[i
].item
;
618 object
->flags
|= NOT_SHALLOW
;
621 struct commit_list
*result
;
623 result
= get_shallow_commits(&want_obj
, depth
,
624 SHALLOW
, NOT_SHALLOW
);
625 send_shallow(result
);
626 free_commit_list(result
);
629 send_unshallow(shallows
);
633 static void deepen_by_rev_list(int ac
, const char **av
,
634 struct object_array
*shallows
)
636 struct commit_list
*result
;
638 result
= get_shallow_commits_by_rev_list(ac
, av
, SHALLOW
, NOT_SHALLOW
);
639 send_shallow(result
);
640 free_commit_list(result
);
641 send_unshallow(shallows
);
645 static void receive_needs(void)
647 struct object_array shallows
= OBJECT_ARRAY_INIT
;
648 struct string_list deepen_not
= STRING_LIST_INIT_DUP
;
651 unsigned long deepen_since
= 0;
652 int deepen_rev_list
= 0;
657 const char *features
;
658 unsigned char sha1_buf
[20];
659 char *line
= packet_read_line(0, NULL
);
666 if (skip_prefix(line
, "shallow ", &arg
)) {
667 unsigned char sha1
[20];
668 struct object
*object
;
669 if (get_sha1_hex(arg
, sha1
))
670 die("invalid shallow line: %s", line
);
671 object
= parse_object(sha1
);
674 if (object
->type
!= OBJ_COMMIT
)
675 die("invalid shallow object %s", sha1_to_hex(sha1
));
676 if (!(object
->flags
& CLIENT_SHALLOW
)) {
677 object
->flags
|= CLIENT_SHALLOW
;
678 add_object_array(object
, NULL
, &shallows
);
682 if (skip_prefix(line
, "deepen ", &arg
)) {
684 depth
= strtol(arg
, &end
, 0);
685 if (!end
|| *end
|| depth
<= 0)
686 die("Invalid deepen: %s", line
);
689 if (skip_prefix(line
, "deepen-since ", &arg
)) {
691 deepen_since
= strtoul(arg
, &end
, 0);
692 if (!end
|| *end
|| !deepen_since
||
693 /* revisions.c's max_age -1 is special */
695 die("Invalid deepen-since: %s", line
);
699 if (skip_prefix(line
, "deepen-not ", &arg
)) {
701 unsigned char sha1
[20];
702 if (expand_ref(arg
, strlen(arg
), sha1
, &ref
) != 1)
703 die("git upload-pack: ambiguous deepen-not: %s", line
);
704 string_list_append(&deepen_not
, ref
);
709 if (!skip_prefix(line
, "want ", &arg
) ||
710 get_sha1_hex(arg
, sha1_buf
))
711 die("git upload-pack: protocol error, "
712 "expected to get sha, not '%s'", line
);
716 if (parse_feature_request(features
, "multi_ack_detailed"))
718 else if (parse_feature_request(features
, "multi_ack"))
720 if (parse_feature_request(features
, "no-done"))
722 if (parse_feature_request(features
, "thin-pack"))
724 if (parse_feature_request(features
, "ofs-delta"))
726 if (parse_feature_request(features
, "side-band-64k"))
727 use_sideband
= LARGE_PACKET_MAX
;
728 else if (parse_feature_request(features
, "side-band"))
729 use_sideband
= DEFAULT_PACKET_MAX
;
730 if (parse_feature_request(features
, "no-progress"))
732 if (parse_feature_request(features
, "include-tag"))
735 o
= parse_object(sha1_buf
);
737 die("git upload-pack: not our ref %s",
738 sha1_to_hex(sha1_buf
));
739 if (!(o
->flags
& WANTED
)) {
743 add_object_array(o
, NULL
, &want_obj
);
748 * We have sent all our refs already, and the other end
749 * should have chosen out of them. When we are operating
750 * in the stateless RPC mode, however, their choice may
751 * have been based on the set of older refs advertised
752 * by another process that handled the initial request.
757 if (!use_sideband
&& daemon_mode
)
760 if (depth
== 0 && !deepen_rev_list
&& shallows
.nr
== 0)
762 if (depth
> 0 && deepen_rev_list
)
763 die("git upload-pack: deepen and deepen-since (or deepen-not) cannot be used together");
765 deepen(depth
, &shallows
);
766 else if (deepen_rev_list
) {
767 struct argv_array av
= ARGV_ARRAY_INIT
;
770 argv_array_push(&av
, "rev-list");
772 argv_array_pushf(&av
, "--max-age=%lu", deepen_since
);
774 argv_array_push(&av
, "--not");
775 for (i
= 0; i
< deepen_not
.nr
; i
++) {
776 struct string_list_item
*s
= deepen_not
.items
+ i
;
777 argv_array_push(&av
, s
->string
);
779 argv_array_push(&av
, "--not");
781 for (i
= 0; i
< want_obj
.nr
; i
++) {
782 struct object
*o
= want_obj
.objects
[i
].item
;
783 argv_array_push(&av
, oid_to_hex(&o
->oid
));
785 deepen_by_rev_list(av
.argc
, av
.argv
, &shallows
);
786 argv_array_clear(&av
);
789 if (shallows
.nr
> 0) {
791 for (i
= 0; i
< shallows
.nr
; i
++)
792 register_shallow(shallows
.objects
[i
].item
->oid
.hash
);
795 shallow_nr
+= shallows
.nr
;
796 free(shallows
.objects
);
799 /* return non-zero if the ref is hidden, otherwise 0 */
800 static int mark_our_ref(const char *refname
, const char *refname_full
,
801 const struct object_id
*oid
)
803 struct object
*o
= lookup_unknown_object(oid
->hash
);
805 if (ref_is_hidden(refname
, refname_full
)) {
806 o
->flags
|= HIDDEN_REF
;
813 static int check_ref(const char *refname_full
, const struct object_id
*oid
,
814 int flag
, void *cb_data
)
816 const char *refname
= strip_namespace(refname_full
);
818 mark_our_ref(refname
, refname_full
, oid
);
822 static void format_symref_info(struct strbuf
*buf
, struct string_list
*symref
)
824 struct string_list_item
*item
;
828 for_each_string_list_item(item
, symref
)
829 strbuf_addf(buf
, " symref=%s:%s", item
->string
, (char *)item
->util
);
832 static int send_ref(const char *refname
, const struct object_id
*oid
,
833 int flag
, void *cb_data
)
835 static const char *capabilities
= "multi_ack thin-pack side-band"
836 " side-band-64k ofs-delta shallow deepen-since deepen-not no-progress"
837 " include-tag multi_ack_detailed";
838 const char *refname_nons
= strip_namespace(refname
);
839 struct object_id peeled
;
841 if (mark_our_ref(refname_nons
, refname
, oid
))
845 struct strbuf symref_info
= STRBUF_INIT
;
847 format_symref_info(&symref_info
, cb_data
);
848 packet_write(1, "%s %s%c%s%s%s%s%s agent=%s\n",
849 oid_to_hex(oid
), refname_nons
,
851 (allow_unadvertised_object_request
& ALLOW_TIP_SHA1
) ?
852 " allow-tip-sha1-in-want" : "",
853 (allow_unadvertised_object_request
& ALLOW_REACHABLE_SHA1
) ?
854 " allow-reachable-sha1-in-want" : "",
855 stateless_rpc
? " no-done" : "",
857 git_user_agent_sanitized());
858 strbuf_release(&symref_info
);
860 packet_write(1, "%s %s\n", oid_to_hex(oid
), refname_nons
);
863 if (!peel_ref(refname
, peeled
.hash
))
864 packet_write(1, "%s %s^{}\n", oid_to_hex(&peeled
), refname_nons
);
868 static int find_symref(const char *refname
, const struct object_id
*oid
,
869 int flag
, void *cb_data
)
871 const char *symref_target
;
872 struct string_list_item
*item
;
873 struct object_id unused
;
875 if ((flag
& REF_ISSYMREF
) == 0)
877 symref_target
= resolve_ref_unsafe(refname
, 0, unused
.hash
, &flag
);
878 if (!symref_target
|| (flag
& REF_ISSYMREF
) == 0)
879 die("'%s' is a symref but it is not?", refname
);
880 item
= string_list_append(cb_data
, refname
);
881 item
->util
= xstrdup(symref_target
);
885 static void upload_pack(void)
887 struct string_list symref
= STRING_LIST_INIT_DUP
;
889 head_ref_namespaced(find_symref
, &symref
);
891 if (advertise_refs
|| !stateless_rpc
) {
893 head_ref_namespaced(send_ref
, &symref
);
894 for_each_namespaced_ref(send_ref
, &symref
);
895 advertise_shallow_grafts(1);
898 head_ref_namespaced(check_ref
, NULL
);
899 for_each_namespaced_ref(check_ref
, NULL
);
901 string_list_clear(&symref
, 1);
907 get_common_commits();
912 static int upload_pack_config(const char *var
, const char *value
, void *unused
)
914 if (!strcmp("uploadpack.allowtipsha1inwant", var
)) {
915 if (git_config_bool(var
, value
))
916 allow_unadvertised_object_request
|= ALLOW_TIP_SHA1
;
918 allow_unadvertised_object_request
&= ~ALLOW_TIP_SHA1
;
919 } else if (!strcmp("uploadpack.allowreachablesha1inwant", var
)) {
920 if (git_config_bool(var
, value
))
921 allow_unadvertised_object_request
|= ALLOW_REACHABLE_SHA1
;
923 allow_unadvertised_object_request
&= ~ALLOW_REACHABLE_SHA1
;
924 } else if (!strcmp("uploadpack.keepalive", var
)) {
925 keepalive
= git_config_int(var
, value
);
929 return parse_hide_refs_config(var
, value
, "uploadpack");
932 int main(int argc
, char **argv
)
940 packet_trace_identity("upload-pack");
941 git_extract_argv0_path(argv
[0]);
942 check_replace_refs
= 0;
944 for (i
= 1; i
< argc
; i
++) {
945 const char *arg
= argv
[i
];
949 if (!strcmp(arg
, "--advertise-refs")) {
953 if (!strcmp(arg
, "--stateless-rpc")) {
957 if (!strcmp(arg
, "--strict")) {
961 if (skip_prefix(arg
, "--timeout=", &arg
)) {
966 if (!strcmp(arg
, "--")) {
973 usage(upload_pack_usage
);
979 if (!enter_repo(dir
, strict
))
980 die("'%s' does not appear to be a git repository", dir
);
982 git_config(upload_pack_config
, NULL
);