11 #include "list-objects.h"
12 #include "run-command.h"
16 #include "string-list.h"
17 #include "parse-options.h"
18 #include "argv-array.h"
20 static const char * const upload_pack_usage[] = {
21 N_("git upload-pack [<options>] <dir>"),
25 /* Remember to update object flag allocation in object.h */
26 #define THEY_HAVE (1u << 11)
27 #define OUR_REF (1u << 12)
28 #define WANTED (1u << 13)
29 #define COMMON_KNOWN (1u << 14)
30 #define REACHABLE (1u << 15)
32 #define SHALLOW (1u << 16)
33 #define NOT_SHALLOW (1u << 17)
34 #define CLIENT_SHALLOW (1u << 18)
35 #define HIDDEN_REF (1u << 19)
37 static unsigned long oldest_have;
39 static int deepen_relative;
42 static int use_thin_pack, use_ofs_delta, use_include_tag;
43 static int no_progress, daemon_mode;
44 /* Allow specifying sha1 if it is a ref tip. */
45 #define ALLOW_TIP_SHA1 01
46 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
47 #define ALLOW_REACHABLE_SHA1 02
48 static unsigned int allow_unadvertised_object_request;
49 static int shallow_nr;
50 static struct object_array have_obj;
51 static struct object_array want_obj;
52 static struct object_array extra_edge_obj;
53 static unsigned int timeout;
54 static int keepalive = 5;
56 * otherwise maximum packet size (up to 65520 bytes).
58 static int use_sideband;
59 static int advertise_refs;
60 static int stateless_rpc;
61 static const char *pack_objects_hook;
63 static void reset_timeout(void)
68 static void send_client_data(int fd, const char *data, ssize_t sz)
71 send_sideband(1, fd, data, sz, use_sideband);
78 /* XXX: are we happy to lose stuff here? */
82 write_or_die(fd, data, sz);
85 static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
88 if (graft->nr_parent == -1)
89 fprintf(fp, "--shallow %s\n", oid_to_hex(&graft->oid));
93 static void create_pack_file(void)
95 struct child_process pack_objects = CHILD_PROCESS_INIT;
96 char data[8193], progress[128];
97 char abort_msg[] = "aborting due to possible repository "
98 "corruption on the remote side.";
104 if (!pack_objects_hook)
105 pack_objects.git_cmd = 1;
107 argv_array_push(&pack_objects.args, pack_objects_hook);
108 argv_array_push(&pack_objects.args, "git");
109 pack_objects.use_shell = 1;
113 argv_array_push(&pack_objects.args, "--shallow-file");
114 argv_array_push(&pack_objects.args, "");
116 argv_array_push(&pack_objects.args, "pack-objects");
117 argv_array_push(&pack_objects.args, "--revs");
119 argv_array_push(&pack_objects.args, "--thin");
121 argv_array_push(&pack_objects.args, "--stdout");
123 argv_array_push(&pack_objects.args, "--shallow");
125 argv_array_push(&pack_objects.args, "--progress");
127 argv_array_push(&pack_objects.args, "--delta-base-offset");
129 argv_array_push(&pack_objects.args, "--include-tag");
131 pack_objects.in = -1;
132 pack_objects.out = -1;
133 pack_objects.err = -1;
135 if (start_command(&pack_objects))
136 die("git upload-pack: unable to fork git-pack-objects");
138 pipe_fd = xfdopen(pack_objects.in, "w");
141 for_each_commit_graft(write_one_shallow, pipe_fd);
143 for (i = 0; i < want_obj.nr; i++)
144 fprintf(pipe_fd, "%s\n",
145 oid_to_hex(&want_obj.objects[i].item->oid));
146 fprintf(pipe_fd, "--not\n");
147 for (i = 0; i < have_obj.nr; i++)
148 fprintf(pipe_fd, "%s\n",
149 oid_to_hex(&have_obj.objects[i].item->oid));
150 for (i = 0; i < extra_edge_obj.nr; i++)
151 fprintf(pipe_fd, "%s\n",
152 oid_to_hex(&extra_edge_obj.objects[i].item->oid));
153 fprintf(pipe_fd, "\n");
157 /* We read from pack_objects.err to capture stderr output for
158 * progress bar, and pack_objects.out to capture the pack data.
162 struct pollfd pfd[2];
163 int pe, pu, pollsize;
171 if (0 <= pack_objects.out) {
172 pfd[pollsize].fd = pack_objects.out;
173 pfd[pollsize].events = POLLIN;
177 if (0 <= pack_objects.err) {
178 pfd[pollsize].fd = pack_objects.err;
179 pfd[pollsize].events = POLLIN;
187 ret = poll(pfd, pollsize,
188 keepalive < 0 ? -1 : 1000 * keepalive);
191 if (errno != EINTR) {
192 error_errno("poll failed, resuming");
197 if (0 <= pe && (pfd[pe].revents & (POLLIN|POLLHUP))) {
198 /* Status ready; we ship that in the side-band
199 * or dump to the standard error.
201 sz = xread(pack_objects.err, progress,
204 send_client_data(2, progress, sz);
206 close(pack_objects.err);
207 pack_objects.err = -1;
211 /* give priority to status messages */
214 if (0 <= pu && (pfd[pu].revents & (POLLIN|POLLHUP))) {
215 /* Data ready; we keep the last byte to ourselves
216 * in case we detect broken rev-list, so that we
217 * can leave the stream corrupted. This is
218 * unfortunate -- unpack-objects would happily
219 * accept a valid packdata with trailing garbage,
220 * so appending garbage after we pass all the
221 * pack data is not good enough to signal
222 * breakage to downstream.
230 sz = xread(pack_objects.out, cp,
231 sizeof(data) - outsz);
235 close(pack_objects.out);
236 pack_objects.out = -1;
242 buffered = data[sz-1] & 0xFF;
247 send_client_data(1, data, sz);
251 * We hit the keepalive timeout without saying anything; send
252 * an empty message on the data sideband just to let the other
253 * side know we're still working on it, but don't have any data
256 * If we don't have a sideband channel, there's no room in the
257 * protocol to say anything, so those clients are just out of
260 if (!ret && use_sideband) {
261 static const char buf[] = "0005\1";
262 write_or_die(1, buf, 5);
266 if (finish_command(&pack_objects)) {
267 error("git upload-pack: git-pack-objects died with error.");
274 send_client_data(1, data, 1);
275 fprintf(stderr, "flushed.\n");
282 send_client_data(3, abort_msg, sizeof(abort_msg));
283 die("git upload-pack: %s", abort_msg);
286 static int got_sha1(const char *hex, unsigned char *sha1)
289 int we_knew_they_have = 0;
291 if (get_sha1_hex(hex, sha1))
292 die("git upload-pack: expected SHA1 object, got '%s'", hex);
293 if (!has_sha1_file(sha1))
296 o = parse_object(sha1);
298 die("oops (%s)", sha1_to_hex(sha1));
299 if (o->type == OBJ_COMMIT) {
300 struct commit_list *parents;
301 struct commit *commit = (struct commit *)o;
302 if (o->flags & THEY_HAVE)
303 we_knew_they_have = 1;
305 o->flags |= THEY_HAVE;
306 if (!oldest_have || (commit->date < oldest_have))
307 oldest_have = commit->date;
308 for (parents = commit->parents;
310 parents = parents->next)
311 parents->item->object.flags |= THEY_HAVE;
313 if (!we_knew_they_have) {
314 add_object_array(o, NULL, &have_obj);
320 static int reachable(struct commit *want)
322 struct commit_list *work = NULL;
324 commit_list_insert_by_date(want, &work);
326 struct commit_list *list;
327 struct commit *commit = pop_commit(&work);
329 if (commit->object.flags & THEY_HAVE) {
330 want->object.flags |= COMMON_KNOWN;
333 if (!commit->object.parsed)
334 parse_object(commit->object.oid.hash);
335 if (commit->object.flags & REACHABLE)
337 commit->object.flags |= REACHABLE;
338 if (commit->date < oldest_have)
340 for (list = commit->parents; list; list = list->next) {
341 struct commit *parent = list->item;
342 if (!(parent->object.flags & REACHABLE))
343 commit_list_insert_by_date(parent, &work);
346 want->object.flags |= REACHABLE;
347 clear_commit_marks(want, REACHABLE);
348 free_commit_list(work);
349 return (want->object.flags & COMMON_KNOWN);
352 static int ok_to_give_up(void)
359 for (i = 0; i < want_obj.nr; i++) {
360 struct object *want = want_obj.objects[i].item;
362 if (want->flags & COMMON_KNOWN)
364 want = deref_tag(want, "a want line", 0);
365 if (!want || want->type != OBJ_COMMIT) {
366 /* no way to tell if this is reachable by
367 * looking at the ancestry chain alone, so
368 * leave a note to ourselves not to worry about
369 * this object anymore.
371 want_obj.objects[i].item->flags |= COMMON_KNOWN;
374 if (!reachable((struct commit *)want))
380 static int get_common_commits(void)
382 unsigned char sha1[20];
388 save_commit_buffer = 0;
391 char *line = packet_read_line(0, NULL);
397 if (multi_ack == 2 && got_common
398 && !got_other && ok_to_give_up()) {
400 packet_write(1, "ACK %s ready\n", last_hex);
402 if (have_obj.nr == 0 || multi_ack)
403 packet_write(1, "NAK\n");
405 if (no_done && sent_ready) {
406 packet_write(1, "ACK %s\n", last_hex);
415 if (skip_prefix(line, "have ", &arg)) {
416 switch (got_sha1(arg, sha1)) {
417 case -1: /* they have what we do not */
419 if (multi_ack && ok_to_give_up()) {
420 const char *hex = sha1_to_hex(sha1);
421 if (multi_ack == 2) {
423 packet_write(1, "ACK %s ready\n", hex);
425 packet_write(1, "ACK %s continue\n", hex);
430 memcpy(last_hex, sha1_to_hex(sha1), 41);
432 packet_write(1, "ACK %s common\n", last_hex);
434 packet_write(1, "ACK %s continue\n", last_hex);
435 else if (have_obj.nr == 1)
436 packet_write(1, "ACK %s\n", last_hex);
441 if (!strcmp(line, "done")) {
442 if (have_obj.nr > 0) {
444 packet_write(1, "ACK %s\n", last_hex);
447 packet_write(1, "NAK\n");
450 die("git upload-pack: expected SHA1 list, got '%s'", line);
454 static int is_our_ref(struct object *o)
456 int allow_hidden_ref = (allow_unadvertised_object_request &
457 (ALLOW_TIP_SHA1 | ALLOW_REACHABLE_SHA1));
458 return o->flags & ((allow_hidden_ref ? HIDDEN_REF : 0) | OUR_REF);
462 * on successful case, it's up to the caller to close cmd->out
464 static int do_reachable_revlist(struct child_process *cmd,
465 struct object_array *src,
466 struct object_array *reachable)
468 static const char *argv[] = {
469 "rev-list", "--stdin", NULL,
472 char namebuf[42]; /* ^ + SHA-1 + LF */
482 * If the next rev-list --stdin encounters an unknown commit,
483 * it terminates, which will cause SIGPIPE in the write loop
486 sigchain_push(SIGPIPE, SIG_IGN);
488 if (start_command(cmd))
493 for (i = get_max_object_index(); 0 < i; ) {
494 o = get_indexed_object(--i);
497 if (reachable && o->type == OBJ_COMMIT)
498 o->flags &= ~TMP_MARK;
501 memcpy(namebuf + 1, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
502 if (write_in_full(cmd->in, namebuf, 42) < 0)
506 for (i = 0; i < src->nr; i++) {
507 o = src->objects[i].item;
510 add_object_array(o, NULL, reachable);
513 if (reachable && o->type == OBJ_COMMIT)
514 o->flags |= TMP_MARK;
515 memcpy(namebuf, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
516 if (write_in_full(cmd->in, namebuf, 41) < 0)
521 sigchain_pop(SIGPIPE);
526 sigchain_pop(SIGPIPE);
535 static int get_reachable_list(struct object_array *src,
536 struct object_array *reachable)
538 struct child_process cmd = CHILD_PROCESS_INIT;
541 char namebuf[42]; /* ^ + SHA-1 + LF */
543 if (do_reachable_revlist(&cmd, src, reachable) < 0)
546 while ((i = read_in_full(cmd.out, namebuf, 41)) == 41) {
547 struct object_id sha1;
549 if (namebuf[40] != '\n' || get_oid_hex(namebuf, &sha1))
552 o = lookup_object(sha1.hash);
553 if (o && o->type == OBJ_COMMIT) {
554 o->flags &= ~TMP_MARK;
557 for (i = get_max_object_index(); 0 < i; i--) {
558 o = get_indexed_object(i - 1);
559 if (o && o->type == OBJ_COMMIT &&
560 (o->flags & TMP_MARK)) {
561 add_object_array(o, NULL, reachable);
562 o->flags &= ~TMP_MARK;
567 if (finish_command(&cmd))
573 static int has_unreachable(struct object_array *src)
575 struct child_process cmd = CHILD_PROCESS_INIT;
579 if (do_reachable_revlist(&cmd, src, NULL) < 0)
583 * The commits out of the rev-list are not ancestors of
586 i = read_in_full(cmd.out, buf, 1);
593 * rev-list may have died by encountering a bad commit
594 * in the history, in which case we do want to bail out
595 * even when it showed no commit.
597 if (finish_command(&cmd))
600 /* All the non-tip ones are ancestors of what we advertised */
604 sigchain_pop(SIGPIPE);
610 static void check_non_tip(void)
615 * In the normal in-process case without
616 * uploadpack.allowReachableSHA1InWant,
617 * non-tip requests can never happen.
619 if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1))
621 if (!has_unreachable(&want_obj))
622 /* All the non-tip ones are ancestors of what we advertised */
626 /* Pick one of them (we know there at least is one) */
627 for (i = 0; i < want_obj.nr; i++) {
628 struct object *o = want_obj.objects[i].item;
630 die("git upload-pack: not our ref %s",
631 oid_to_hex(&o->oid));
635 static void send_shallow(struct commit_list *result)
638 struct object *object = &result->item->object;
639 if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
640 packet_write(1, "shallow %s",
641 oid_to_hex(&object->oid));
642 register_shallow(object->oid.hash);
645 result = result->next;
649 static void send_unshallow(const struct object_array *shallows)
653 for (i = 0; i < shallows->nr; i++) {
654 struct object *object = shallows->objects[i].item;
655 if (object->flags & NOT_SHALLOW) {
656 struct commit_list *parents;
657 packet_write(1, "unshallow %s",
658 oid_to_hex(&object->oid));
659 object->flags &= ~CLIENT_SHALLOW;
661 * We want to _register_ "object" as shallow, but we
662 * also need to traverse object's parents to deepen a
663 * shallow clone. Unregister it for now so we can
664 * parse and add the parents to the want list, then
667 unregister_shallow(object->oid.hash);
669 parse_commit_or_die((struct commit *)object);
670 parents = ((struct commit *)object)->parents;
672 add_object_array(&parents->item->object,
674 parents = parents->next;
676 add_object_array(object, NULL, &extra_edge_obj);
678 /* make sure commit traversal conforms to client */
679 register_shallow(object->oid.hash);
683 static void deepen(int depth, int deepen_relative,
684 struct object_array *shallows)
686 if (depth == INFINITE_DEPTH && !is_repository_shallow()) {
689 for (i = 0; i < shallows->nr; i++) {
690 struct object *object = shallows->objects[i].item;
691 object->flags |= NOT_SHALLOW;
693 } else if (deepen_relative) {
694 struct object_array reachable_shallows = OBJECT_ARRAY_INIT;
695 struct commit_list *result;
697 get_reachable_list(shallows, &reachable_shallows);
698 result = get_shallow_commits(&reachable_shallows,
700 SHALLOW, NOT_SHALLOW);
701 send_shallow(result);
702 free_commit_list(result);
703 object_array_clear(&reachable_shallows);
705 struct commit_list *result;
707 result = get_shallow_commits(&want_obj, depth,
708 SHALLOW, NOT_SHALLOW);
709 send_shallow(result);
710 free_commit_list(result);
713 send_unshallow(shallows);
717 static void deepen_by_rev_list(int ac, const char **av,
718 struct object_array *shallows)
720 struct commit_list *result;
722 result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
723 send_shallow(result);
724 free_commit_list(result);
725 send_unshallow(shallows);
729 static void receive_needs(void)
731 struct object_array shallows = OBJECT_ARRAY_INIT;
732 struct string_list deepen_not = STRING_LIST_INIT_DUP;
735 unsigned long deepen_since = 0;
736 int deepen_rev_list = 0;
741 const char *features;
742 unsigned char sha1_buf[20];
743 char *line = packet_read_line(0, NULL);
750 if (skip_prefix(line, "shallow ", &arg)) {
751 unsigned char sha1[20];
752 struct object *object;
753 if (get_sha1_hex(arg, sha1))
754 die("invalid shallow line: %s", line);
755 object = parse_object(sha1);
758 if (object->type != OBJ_COMMIT)
759 die("invalid shallow object %s", sha1_to_hex(sha1));
760 if (!(object->flags & CLIENT_SHALLOW)) {
761 object->flags |= CLIENT_SHALLOW;
762 add_object_array(object, NULL, &shallows);
766 if (skip_prefix(line, "deepen ", &arg)) {
768 depth = strtol(arg, &end, 0);
769 if (!end || *end || depth <= 0)
770 die("Invalid deepen: %s", line);
773 if (skip_prefix(line, "deepen-since ", &arg)) {
775 deepen_since = strtoul(arg, &end, 0);
776 if (!end || *end || !deepen_since ||
777 /* revisions.c's max_age -1 is special */
779 die("Invalid deepen-since: %s", line);
783 if (skip_prefix(line, "deepen-not ", &arg)) {
785 unsigned char sha1[20];
786 if (expand_ref(arg, strlen(arg), sha1, &ref) != 1)
787 die("git upload-pack: ambiguous deepen-not: %s", line);
788 string_list_append(&deepen_not, ref);
793 if (!skip_prefix(line, "want ", &arg) ||
794 get_sha1_hex(arg, sha1_buf))
795 die("git upload-pack: protocol error, "
796 "expected to get sha, not '%s'", line);
800 if (parse_feature_request(features, "deepen-relative"))
802 if (parse_feature_request(features, "multi_ack_detailed"))
804 else if (parse_feature_request(features, "multi_ack"))
806 if (parse_feature_request(features, "no-done"))
808 if (parse_feature_request(features, "thin-pack"))
810 if (parse_feature_request(features, "ofs-delta"))
812 if (parse_feature_request(features, "side-band-64k"))
813 use_sideband = LARGE_PACKET_MAX;
814 else if (parse_feature_request(features, "side-band"))
815 use_sideband = DEFAULT_PACKET_MAX;
816 if (parse_feature_request(features, "no-progress"))
818 if (parse_feature_request(features, "include-tag"))
821 o = parse_object(sha1_buf);
823 die("git upload-pack: not our ref %s",
824 sha1_to_hex(sha1_buf));
825 if (!(o->flags & WANTED)) {
829 add_object_array(o, NULL, &want_obj);
834 * We have sent all our refs already, and the other end
835 * should have chosen out of them. When we are operating
836 * in the stateless RPC mode, however, their choice may
837 * have been based on the set of older refs advertised
838 * by another process that handled the initial request.
843 if (!use_sideband && daemon_mode)
846 if (depth == 0 && !deepen_rev_list && shallows.nr == 0)
848 if (depth > 0 && deepen_rev_list)
849 die("git upload-pack: deepen and deepen-since (or deepen-not) cannot be used together");
851 deepen(depth, deepen_relative, &shallows);
852 else if (deepen_rev_list) {
853 struct argv_array av = ARGV_ARRAY_INIT;
856 argv_array_push(&av, "rev-list");
858 argv_array_pushf(&av, "--max-age=%lu", deepen_since);
860 argv_array_push(&av, "--not");
861 for (i = 0; i < deepen_not.nr; i++) {
862 struct string_list_item *s = deepen_not.items + i;
863 argv_array_push(&av, s->string);
865 argv_array_push(&av, "--not");
867 for (i = 0; i < want_obj.nr; i++) {
868 struct object *o = want_obj.objects[i].item;
869 argv_array_push(&av, oid_to_hex(&o->oid));
871 deepen_by_rev_list(av.argc, av.argv, &shallows);
872 argv_array_clear(&av);
875 if (shallows.nr > 0) {
877 for (i = 0; i < shallows.nr; i++)
878 register_shallow(shallows.objects[i].item->oid.hash);
881 shallow_nr += shallows.nr;
882 free(shallows.objects);
885 /* return non-zero if the ref is hidden, otherwise 0 */
886 static int mark_our_ref(const char *refname, const char *refname_full,
887 const struct object_id *oid)
889 struct object *o = lookup_unknown_object(oid->hash);
891 if (ref_is_hidden(refname, refname_full)) {
892 o->flags |= HIDDEN_REF;
899 static int check_ref(const char *refname_full, const struct object_id *oid,
900 int flag, void *cb_data)
902 const char *refname = strip_namespace(refname_full);
904 mark_our_ref(refname, refname_full, oid);
908 static void format_symref_info(struct strbuf *buf, struct string_list *symref)
910 struct string_list_item *item;
914 for_each_string_list_item(item, symref)
915 strbuf_addf(buf, " symref=%s:%s", item->string, (char *)item->util);
918 static int send_ref(const char *refname, const struct object_id *oid,
919 int flag, void *cb_data)
921 static const char *capabilities = "multi_ack thin-pack side-band"
922 " side-band-64k ofs-delta shallow deepen-since deepen-not"
923 " deepen-relative no-progress include-tag multi_ack_detailed";
924 const char *refname_nons = strip_namespace(refname);
925 struct object_id peeled;
927 if (mark_our_ref(refname_nons, refname, oid))
931 struct strbuf symref_info = STRBUF_INIT;
933 format_symref_info(&symref_info, cb_data);
934 packet_write(1, "%s %s%c%s%s%s%s%s agent=%s\n",
935 oid_to_hex(oid), refname_nons,
937 (allow_unadvertised_object_request & ALLOW_TIP_SHA1) ?
938 " allow-tip-sha1-in-want" : "",
939 (allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1) ?
940 " allow-reachable-sha1-in-want" : "",
941 stateless_rpc ? " no-done" : "",
943 git_user_agent_sanitized());
944 strbuf_release(&symref_info);
946 packet_write(1, "%s %s\n", oid_to_hex(oid), refname_nons);
949 if (!peel_ref(refname, peeled.hash))
950 packet_write(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons);
954 static int find_symref(const char *refname, const struct object_id *oid,
955 int flag, void *cb_data)
957 const char *symref_target;
958 struct string_list_item *item;
959 struct object_id unused;
961 if ((flag & REF_ISSYMREF) == 0)
963 symref_target = resolve_ref_unsafe(refname, 0, unused.hash, &flag);
964 if (!symref_target || (flag & REF_ISSYMREF) == 0)
965 die("'%s' is a symref but it is not?", refname);
966 item = string_list_append(cb_data, refname);
967 item->util = xstrdup(symref_target);
971 static void upload_pack(void)
973 struct string_list symref = STRING_LIST_INIT_DUP;
975 head_ref_namespaced(find_symref, &symref);
977 if (advertise_refs || !stateless_rpc) {
979 head_ref_namespaced(send_ref, &symref);
980 for_each_namespaced_ref(send_ref, &symref);
981 advertise_shallow_grafts(1);
984 head_ref_namespaced(check_ref, NULL);
985 for_each_namespaced_ref(check_ref, NULL);
987 string_list_clear(&symref, 1);
993 get_common_commits();
998 static int upload_pack_config(const char *var, const char *value, void *unused)
1000 if (!strcmp("uploadpack.allowtipsha1inwant", var)) {
1001 if (git_config_bool(var, value))
1002 allow_unadvertised_object_request |= ALLOW_TIP_SHA1;
1004 allow_unadvertised_object_request &= ~ALLOW_TIP_SHA1;
1005 } else if (!strcmp("uploadpack.allowreachablesha1inwant", var)) {
1006 if (git_config_bool(var, value))
1007 allow_unadvertised_object_request |= ALLOW_REACHABLE_SHA1;
1009 allow_unadvertised_object_request &= ~ALLOW_REACHABLE_SHA1;
1010 } else if (!strcmp("uploadpack.keepalive", var)) {
1011 keepalive = git_config_int(var, value);
1014 } else if (current_config_scope() != CONFIG_SCOPE_REPO) {
1015 if (!strcmp("uploadpack.packobjectshook", var))
1016 return git_config_string(&pack_objects_hook, var, value);
1018 return parse_hide_refs_config(var, value, "uploadpack");
1021 int cmd_main(int argc, const char **argv)
1025 struct option options[] = {
1026 OPT_BOOL(0, "stateless-rpc", &stateless_rpc,
1027 N_("quit after a single request/response exchange")),
1028 OPT_BOOL(0, "advertise-refs", &advertise_refs,
1029 N_("exit immediately after initial ref advertisement")),
1030 OPT_BOOL(0, "strict", &strict,
1031 N_("do not try <directory>/.git/ if <directory> is no Git directory")),
1032 OPT_INTEGER(0, "timeout", &timeout,
1033 N_("interrupt transfer after <n> seconds of inactivity")),
1037 packet_trace_identity("upload-pack");
1038 check_replace_refs = 0;
1040 argc = parse_options(argc, argv, NULL, options, upload_pack_usage, 0);
1043 usage_with_options(upload_pack_usage, options);
1052 if (!enter_repo(dir, strict))
1053 die("'%s' does not appear to be a git repository", dir);
1055 git_config(upload_pack_config, NULL);