11 #include "list-objects.h"
12 #include "run-command.h"
16 #include "string-list.h"
17 #include "argv-array.h"
18 #include "prio-queue.h"
20 #include "upload-pack.h"
22 /* Remember to update object flag allocation in object.h */
23 #define THEY_HAVE (1u << 11)
24 #define OUR_REF (1u << 12)
25 #define WANTED (1u << 13)
26 #define COMMON_KNOWN (1u << 14)
27 #define REACHABLE (1u << 15)
29 #define SHALLOW (1u << 16)
30 #define NOT_SHALLOW (1u << 17)
31 #define CLIENT_SHALLOW (1u << 18)
32 #define HIDDEN_REF (1u << 19)
34 static timestamp_t oldest_have;
36 static int deepen_relative;
39 static int use_thin_pack, use_ofs_delta, use_include_tag;
40 static int no_progress, daemon_mode;
41 /* Allow specifying sha1 if it is a ref tip. */
42 #define ALLOW_TIP_SHA1 01
43 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
44 #define ALLOW_REACHABLE_SHA1 02
45 /* Allow request of any sha1. Implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1. */
46 #define ALLOW_ANY_SHA1 07
47 static unsigned int allow_unadvertised_object_request;
48 static int shallow_nr;
49 static struct object_array have_obj;
50 static struct object_array want_obj;
51 static struct object_array extra_edge_obj;
52 static unsigned int timeout;
53 static int keepalive = 5;
55 * otherwise maximum packet size (up to 65520 bytes).
57 static int use_sideband;
58 static int stateless_rpc;
59 static const char *pack_objects_hook;
61 static void reset_timeout(void)
66 static void send_client_data(int fd, const char *data, ssize_t sz)
69 send_sideband(1, fd, data, sz, use_sideband);
76 /* XXX: are we happy to lose stuff here? */
80 write_or_die(fd, data, sz);
83 static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
86 if (graft->nr_parent == -1)
87 fprintf(fp, "--shallow %s\n", oid_to_hex(&graft->oid));
91 static void create_pack_file(void)
93 struct child_process pack_objects = CHILD_PROCESS_INIT;
94 char data[8193], progress[128];
95 char abort_msg[] = "aborting due to possible repository "
96 "corruption on the remote side.";
102 if (!pack_objects_hook)
103 pack_objects.git_cmd = 1;
105 argv_array_push(&pack_objects.args, pack_objects_hook);
106 argv_array_push(&pack_objects.args, "git");
107 pack_objects.use_shell = 1;
111 argv_array_push(&pack_objects.args, "--shallow-file");
112 argv_array_push(&pack_objects.args, "");
114 argv_array_push(&pack_objects.args, "pack-objects");
115 argv_array_push(&pack_objects.args, "--revs");
117 argv_array_push(&pack_objects.args, "--thin");
119 argv_array_push(&pack_objects.args, "--stdout");
121 argv_array_push(&pack_objects.args, "--shallow");
123 argv_array_push(&pack_objects.args, "--progress");
125 argv_array_push(&pack_objects.args, "--delta-base-offset");
127 argv_array_push(&pack_objects.args, "--include-tag");
129 pack_objects.in = -1;
130 pack_objects.out = -1;
131 pack_objects.err = -1;
133 if (start_command(&pack_objects))
134 die("git upload-pack: unable to fork git-pack-objects");
136 pipe_fd = xfdopen(pack_objects.in, "w");
139 for_each_commit_graft(write_one_shallow, pipe_fd);
141 for (i = 0; i < want_obj.nr; i++)
142 fprintf(pipe_fd, "%s\n",
143 oid_to_hex(&want_obj.objects[i].item->oid));
144 fprintf(pipe_fd, "--not\n");
145 for (i = 0; i < have_obj.nr; i++)
146 fprintf(pipe_fd, "%s\n",
147 oid_to_hex(&have_obj.objects[i].item->oid));
148 for (i = 0; i < extra_edge_obj.nr; i++)
149 fprintf(pipe_fd, "%s\n",
150 oid_to_hex(&extra_edge_obj.objects[i].item->oid));
151 fprintf(pipe_fd, "\n");
155 /* We read from pack_objects.err to capture stderr output for
156 * progress bar, and pack_objects.out to capture the pack data.
160 struct pollfd pfd[2];
161 int pe, pu, pollsize;
169 if (0 <= pack_objects.out) {
170 pfd[pollsize].fd = pack_objects.out;
171 pfd[pollsize].events = POLLIN;
175 if (0 <= pack_objects.err) {
176 pfd[pollsize].fd = pack_objects.err;
177 pfd[pollsize].events = POLLIN;
185 ret = poll(pfd, pollsize,
186 keepalive < 0 ? -1 : 1000 * keepalive);
189 if (errno != EINTR) {
190 error_errno("poll failed, resuming");
195 if (0 <= pe && (pfd[pe].revents & (POLLIN|POLLHUP))) {
196 /* Status ready; we ship that in the side-band
197 * or dump to the standard error.
199 sz = xread(pack_objects.err, progress,
202 send_client_data(2, progress, sz);
204 close(pack_objects.err);
205 pack_objects.err = -1;
209 /* give priority to status messages */
212 if (0 <= pu && (pfd[pu].revents & (POLLIN|POLLHUP))) {
213 /* Data ready; we keep the last byte to ourselves
214 * in case we detect broken rev-list, so that we
215 * can leave the stream corrupted. This is
216 * unfortunate -- unpack-objects would happily
217 * accept a valid packdata with trailing garbage,
218 * so appending garbage after we pass all the
219 * pack data is not good enough to signal
220 * breakage to downstream.
228 sz = xread(pack_objects.out, cp,
229 sizeof(data) - outsz);
233 close(pack_objects.out);
234 pack_objects.out = -1;
240 buffered = data[sz-1] & 0xFF;
245 send_client_data(1, data, sz);
249 * We hit the keepalive timeout without saying anything; send
250 * an empty message on the data sideband just to let the other
251 * side know we're still working on it, but don't have any data
254 * If we don't have a sideband channel, there's no room in the
255 * protocol to say anything, so those clients are just out of
258 if (!ret && use_sideband) {
259 static const char buf[] = "0005\1";
260 write_or_die(1, buf, 5);
264 if (finish_command(&pack_objects)) {
265 error("git upload-pack: git-pack-objects died with error.");
272 send_client_data(1, data, 1);
273 fprintf(stderr, "flushed.\n");
280 send_client_data(3, abort_msg, sizeof(abort_msg));
281 die("git upload-pack: %s", abort_msg);
284 static int got_oid(const char *hex, struct object_id *oid)
287 int we_knew_they_have = 0;
289 if (get_oid_hex(hex, oid))
290 die("git upload-pack: expected SHA1 object, got '%s'", hex);
291 if (!has_object_file(oid))
294 o = parse_object(oid);
296 die("oops (%s)", oid_to_hex(oid));
297 if (o->type == OBJ_COMMIT) {
298 struct commit_list *parents;
299 struct commit *commit = (struct commit *)o;
300 if (o->flags & THEY_HAVE)
301 we_knew_they_have = 1;
303 o->flags |= THEY_HAVE;
304 if (!oldest_have || (commit->date < oldest_have))
305 oldest_have = commit->date;
306 for (parents = commit->parents;
308 parents = parents->next)
309 parents->item->object.flags |= THEY_HAVE;
311 if (!we_knew_they_have) {
312 add_object_array(o, NULL, &have_obj);
318 static int reachable(struct commit *want)
320 struct prio_queue work = { compare_commits_by_commit_date };
322 prio_queue_put(&work, want);
324 struct commit_list *list;
325 struct commit *commit = prio_queue_get(&work);
327 if (commit->object.flags & THEY_HAVE) {
328 want->object.flags |= COMMON_KNOWN;
331 if (!commit->object.parsed)
332 parse_object(&commit->object.oid);
333 if (commit->object.flags & REACHABLE)
335 commit->object.flags |= REACHABLE;
336 if (commit->date < oldest_have)
338 for (list = commit->parents; list; list = list->next) {
339 struct commit *parent = list->item;
340 if (!(parent->object.flags & REACHABLE))
341 prio_queue_put(&work, parent);
344 want->object.flags |= REACHABLE;
345 clear_commit_marks(want, REACHABLE);
346 clear_prio_queue(&work);
347 return (want->object.flags & COMMON_KNOWN);
350 static int ok_to_give_up(void)
357 for (i = 0; i < want_obj.nr; i++) {
358 struct object *want = want_obj.objects[i].item;
360 if (want->flags & COMMON_KNOWN)
362 want = deref_tag(want, "a want line", 0);
363 if (!want || want->type != OBJ_COMMIT) {
364 /* no way to tell if this is reachable by
365 * looking at the ancestry chain alone, so
366 * leave a note to ourselves not to worry about
367 * this object anymore.
369 want_obj.objects[i].item->flags |= COMMON_KNOWN;
372 if (!reachable((struct commit *)want))
378 static int get_common_commits(void)
380 struct object_id oid;
381 char last_hex[GIT_MAX_HEXSZ + 1];
386 save_commit_buffer = 0;
389 char *line = packet_read_line(0, NULL);
395 if (multi_ack == 2 && got_common
396 && !got_other && ok_to_give_up()) {
398 packet_write_fmt(1, "ACK %s ready\n", last_hex);
400 if (have_obj.nr == 0 || multi_ack)
401 packet_write_fmt(1, "NAK\n");
403 if (no_done && sent_ready) {
404 packet_write_fmt(1, "ACK %s\n", last_hex);
413 if (skip_prefix(line, "have ", &arg)) {
414 switch (got_oid(arg, &oid)) {
415 case -1: /* they have what we do not */
417 if (multi_ack && ok_to_give_up()) {
418 const char *hex = oid_to_hex(&oid);
419 if (multi_ack == 2) {
421 packet_write_fmt(1, "ACK %s ready\n", hex);
423 packet_write_fmt(1, "ACK %s continue\n", hex);
428 memcpy(last_hex, oid_to_hex(&oid), 41);
430 packet_write_fmt(1, "ACK %s common\n", last_hex);
432 packet_write_fmt(1, "ACK %s continue\n", last_hex);
433 else if (have_obj.nr == 1)
434 packet_write_fmt(1, "ACK %s\n", last_hex);
439 if (!strcmp(line, "done")) {
440 if (have_obj.nr > 0) {
442 packet_write_fmt(1, "ACK %s\n", last_hex);
445 packet_write_fmt(1, "NAK\n");
448 die("git upload-pack: expected SHA1 list, got '%s'", line);
452 static int is_our_ref(struct object *o)
454 int allow_hidden_ref = (allow_unadvertised_object_request &
455 (ALLOW_TIP_SHA1 | ALLOW_REACHABLE_SHA1));
456 return o->flags & ((allow_hidden_ref ? HIDDEN_REF : 0) | OUR_REF);
460 * on successful case, it's up to the caller to close cmd->out
462 static int do_reachable_revlist(struct child_process *cmd,
463 struct object_array *src,
464 struct object_array *reachable)
466 static const char *argv[] = {
467 "rev-list", "--stdin", NULL,
470 char namebuf[42]; /* ^ + SHA-1 + LF */
480 * If the next rev-list --stdin encounters an unknown commit,
481 * it terminates, which will cause SIGPIPE in the write loop
484 sigchain_push(SIGPIPE, SIG_IGN);
486 if (start_command(cmd))
490 namebuf[GIT_SHA1_HEXSZ + 1] = '\n';
491 for (i = get_max_object_index(); 0 < i; ) {
492 o = get_indexed_object(--i);
495 if (reachable && o->type == OBJ_COMMIT)
496 o->flags &= ~TMP_MARK;
499 memcpy(namebuf + 1, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
500 if (write_in_full(cmd->in, namebuf, GIT_SHA1_HEXSZ + 2) < 0)
503 namebuf[GIT_SHA1_HEXSZ] = '\n';
504 for (i = 0; i < src->nr; i++) {
505 o = src->objects[i].item;
508 add_object_array(o, NULL, reachable);
511 if (reachable && o->type == OBJ_COMMIT)
512 o->flags |= TMP_MARK;
513 memcpy(namebuf, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
514 if (write_in_full(cmd->in, namebuf, GIT_SHA1_HEXSZ + 1) < 0)
519 sigchain_pop(SIGPIPE);
524 sigchain_pop(SIGPIPE);
533 static int get_reachable_list(struct object_array *src,
534 struct object_array *reachable)
536 struct child_process cmd = CHILD_PROCESS_INIT;
539 char namebuf[42]; /* ^ + SHA-1 + LF */
541 if (do_reachable_revlist(&cmd, src, reachable) < 0)
544 while ((i = read_in_full(cmd.out, namebuf, 41)) == 41) {
545 struct object_id sha1;
547 if (namebuf[40] != '\n' || get_oid_hex(namebuf, &sha1))
550 o = lookup_object(sha1.hash);
551 if (o && o->type == OBJ_COMMIT) {
552 o->flags &= ~TMP_MARK;
555 for (i = get_max_object_index(); 0 < i; i--) {
556 o = get_indexed_object(i - 1);
557 if (o && o->type == OBJ_COMMIT &&
558 (o->flags & TMP_MARK)) {
559 add_object_array(o, NULL, reachable);
560 o->flags &= ~TMP_MARK;
565 if (finish_command(&cmd))
571 static int has_unreachable(struct object_array *src)
573 struct child_process cmd = CHILD_PROCESS_INIT;
577 if (do_reachable_revlist(&cmd, src, NULL) < 0)
581 * The commits out of the rev-list are not ancestors of
584 i = read_in_full(cmd.out, buf, 1);
591 * rev-list may have died by encountering a bad commit
592 * in the history, in which case we do want to bail out
593 * even when it showed no commit.
595 if (finish_command(&cmd))
598 /* All the non-tip ones are ancestors of what we advertised */
602 sigchain_pop(SIGPIPE);
608 static void check_non_tip(void)
613 * In the normal in-process case without
614 * uploadpack.allowReachableSHA1InWant,
615 * non-tip requests can never happen.
617 if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1))
619 if (!has_unreachable(&want_obj))
620 /* All the non-tip ones are ancestors of what we advertised */
624 /* Pick one of them (we know there at least is one) */
625 for (i = 0; i < want_obj.nr; i++) {
626 struct object *o = want_obj.objects[i].item;
628 die("git upload-pack: not our ref %s",
629 oid_to_hex(&o->oid));
633 static void send_shallow(struct commit_list *result)
636 struct object *object = &result->item->object;
637 if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
638 packet_write_fmt(1, "shallow %s",
639 oid_to_hex(&object->oid));
640 register_shallow(&object->oid);
643 result = result->next;
647 static void send_unshallow(const struct object_array *shallows)
651 for (i = 0; i < shallows->nr; i++) {
652 struct object *object = shallows->objects[i].item;
653 if (object->flags & NOT_SHALLOW) {
654 struct commit_list *parents;
655 packet_write_fmt(1, "unshallow %s",
656 oid_to_hex(&object->oid));
657 object->flags &= ~CLIENT_SHALLOW;
659 * We want to _register_ "object" as shallow, but we
660 * also need to traverse object's parents to deepen a
661 * shallow clone. Unregister it for now so we can
662 * parse and add the parents to the want list, then
665 unregister_shallow(&object->oid);
667 parse_commit_or_die((struct commit *)object);
668 parents = ((struct commit *)object)->parents;
670 add_object_array(&parents->item->object,
672 parents = parents->next;
674 add_object_array(object, NULL, &extra_edge_obj);
676 /* make sure commit traversal conforms to client */
677 register_shallow(&object->oid);
681 static void deepen(int depth, int deepen_relative,
682 struct object_array *shallows)
684 if (depth == INFINITE_DEPTH && !is_repository_shallow()) {
687 for (i = 0; i < shallows->nr; i++) {
688 struct object *object = shallows->objects[i].item;
689 object->flags |= NOT_SHALLOW;
691 } else if (deepen_relative) {
692 struct object_array reachable_shallows = OBJECT_ARRAY_INIT;
693 struct commit_list *result;
695 get_reachable_list(shallows, &reachable_shallows);
696 result = get_shallow_commits(&reachable_shallows,
698 SHALLOW, NOT_SHALLOW);
699 send_shallow(result);
700 free_commit_list(result);
701 object_array_clear(&reachable_shallows);
703 struct commit_list *result;
705 result = get_shallow_commits(&want_obj, depth,
706 SHALLOW, NOT_SHALLOW);
707 send_shallow(result);
708 free_commit_list(result);
711 send_unshallow(shallows);
715 static void deepen_by_rev_list(int ac, const char **av,
716 struct object_array *shallows)
718 struct commit_list *result;
720 result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
721 send_shallow(result);
722 free_commit_list(result);
723 send_unshallow(shallows);
727 static void receive_needs(void)
729 struct object_array shallows = OBJECT_ARRAY_INIT;
730 struct string_list deepen_not = STRING_LIST_INIT_DUP;
733 timestamp_t deepen_since = 0;
734 int deepen_rev_list = 0;
739 const char *features;
740 struct object_id oid_buf;
741 char *line = packet_read_line(0, NULL);
748 if (skip_prefix(line, "shallow ", &arg)) {
749 struct object_id oid;
750 struct object *object;
751 if (get_oid_hex(arg, &oid))
752 die("invalid shallow line: %s", line);
753 object = parse_object(&oid);
756 if (object->type != OBJ_COMMIT)
757 die("invalid shallow object %s", oid_to_hex(&oid));
758 if (!(object->flags & CLIENT_SHALLOW)) {
759 object->flags |= CLIENT_SHALLOW;
760 add_object_array(object, NULL, &shallows);
764 if (skip_prefix(line, "deepen ", &arg)) {
766 depth = strtol(arg, &end, 0);
767 if (!end || *end || depth <= 0)
768 die("Invalid deepen: %s", line);
771 if (skip_prefix(line, "deepen-since ", &arg)) {
773 deepen_since = parse_timestamp(arg, &end, 0);
774 if (!end || *end || !deepen_since ||
775 /* revisions.c's max_age -1 is special */
777 die("Invalid deepen-since: %s", line);
781 if (skip_prefix(line, "deepen-not ", &arg)) {
783 struct object_id oid;
784 if (expand_ref(arg, strlen(arg), &oid, &ref) != 1)
785 die("git upload-pack: ambiguous deepen-not: %s", line);
786 string_list_append(&deepen_not, ref);
791 if (!skip_prefix(line, "want ", &arg) ||
792 get_oid_hex(arg, &oid_buf))
793 die("git upload-pack: protocol error, "
794 "expected to get sha, not '%s'", line);
798 if (parse_feature_request(features, "deepen-relative"))
800 if (parse_feature_request(features, "multi_ack_detailed"))
802 else if (parse_feature_request(features, "multi_ack"))
804 if (parse_feature_request(features, "no-done"))
806 if (parse_feature_request(features, "thin-pack"))
808 if (parse_feature_request(features, "ofs-delta"))
810 if (parse_feature_request(features, "side-band-64k"))
811 use_sideband = LARGE_PACKET_MAX;
812 else if (parse_feature_request(features, "side-band"))
813 use_sideband = DEFAULT_PACKET_MAX;
814 if (parse_feature_request(features, "no-progress"))
816 if (parse_feature_request(features, "include-tag"))
819 o = parse_object(&oid_buf);
822 "ERR upload-pack: not our ref %s",
823 oid_to_hex(&oid_buf));
824 die("git upload-pack: not our ref %s",
825 oid_to_hex(&oid_buf));
827 if (!(o->flags & WANTED)) {
829 if (!((allow_unadvertised_object_request & ALLOW_ANY_SHA1) == ALLOW_ANY_SHA1
832 add_object_array(o, NULL, &want_obj);
837 * We have sent all our refs already, and the other end
838 * should have chosen out of them. When we are operating
839 * in the stateless RPC mode, however, their choice may
840 * have been based on the set of older refs advertised
841 * by another process that handled the initial request.
846 if (!use_sideband && daemon_mode)
849 if (depth == 0 && !deepen_rev_list && shallows.nr == 0)
851 if (depth > 0 && deepen_rev_list)
852 die("git upload-pack: deepen and deepen-since (or deepen-not) cannot be used together");
854 deepen(depth, deepen_relative, &shallows);
855 else if (deepen_rev_list) {
856 struct argv_array av = ARGV_ARRAY_INIT;
859 argv_array_push(&av, "rev-list");
861 argv_array_pushf(&av, "--max-age=%"PRItime, deepen_since);
863 argv_array_push(&av, "--not");
864 for (i = 0; i < deepen_not.nr; i++) {
865 struct string_list_item *s = deepen_not.items + i;
866 argv_array_push(&av, s->string);
868 argv_array_push(&av, "--not");
870 for (i = 0; i < want_obj.nr; i++) {
871 struct object *o = want_obj.objects[i].item;
872 argv_array_push(&av, oid_to_hex(&o->oid));
874 deepen_by_rev_list(av.argc, av.argv, &shallows);
875 argv_array_clear(&av);
878 if (shallows.nr > 0) {
880 for (i = 0; i < shallows.nr; i++)
881 register_shallow(&shallows.objects[i].item->oid);
884 shallow_nr += shallows.nr;
885 object_array_clear(&shallows);
888 /* return non-zero if the ref is hidden, otherwise 0 */
889 static int mark_our_ref(const char *refname, const char *refname_full,
890 const struct object_id *oid)
892 struct object *o = lookup_unknown_object(oid->hash);
894 if (ref_is_hidden(refname, refname_full)) {
895 o->flags |= HIDDEN_REF;
902 static int check_ref(const char *refname_full, const struct object_id *oid,
903 int flag, void *cb_data)
905 const char *refname = strip_namespace(refname_full);
907 mark_our_ref(refname, refname_full, oid);
911 static void format_symref_info(struct strbuf *buf, struct string_list *symref)
913 struct string_list_item *item;
917 for_each_string_list_item(item, symref)
918 strbuf_addf(buf, " symref=%s:%s", item->string, (char *)item->util);
921 static int send_ref(const char *refname, const struct object_id *oid,
922 int flag, void *cb_data)
924 static const char *capabilities = "multi_ack thin-pack side-band"
925 " side-band-64k ofs-delta shallow deepen-since deepen-not"
926 " deepen-relative no-progress include-tag multi_ack_detailed";
927 const char *refname_nons = strip_namespace(refname);
928 struct object_id peeled;
930 if (mark_our_ref(refname_nons, refname, oid))
934 struct strbuf symref_info = STRBUF_INIT;
936 format_symref_info(&symref_info, cb_data);
937 packet_write_fmt(1, "%s %s%c%s%s%s%s%s agent=%s\n",
938 oid_to_hex(oid), refname_nons,
940 (allow_unadvertised_object_request & ALLOW_TIP_SHA1) ?
941 " allow-tip-sha1-in-want" : "",
942 (allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1) ?
943 " allow-reachable-sha1-in-want" : "",
944 stateless_rpc ? " no-done" : "",
946 git_user_agent_sanitized());
947 strbuf_release(&symref_info);
949 packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons);
952 if (!peel_ref(refname, &peeled))
953 packet_write_fmt(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons);
957 static int find_symref(const char *refname, const struct object_id *oid,
958 int flag, void *cb_data)
960 const char *symref_target;
961 struct string_list_item *item;
963 if ((flag & REF_ISSYMREF) == 0)
965 symref_target = resolve_ref_unsafe(refname, 0, NULL, &flag);
966 if (!symref_target || (flag & REF_ISSYMREF) == 0)
967 die("'%s' is a symref but it is not?", refname);
968 item = string_list_append(cb_data, refname);
969 item->util = xstrdup(symref_target);
973 static int upload_pack_config(const char *var, const char *value, void *unused)
975 if (!strcmp("uploadpack.allowtipsha1inwant", var)) {
976 if (git_config_bool(var, value))
977 allow_unadvertised_object_request |= ALLOW_TIP_SHA1;
979 allow_unadvertised_object_request &= ~ALLOW_TIP_SHA1;
980 } else if (!strcmp("uploadpack.allowreachablesha1inwant", var)) {
981 if (git_config_bool(var, value))
982 allow_unadvertised_object_request |= ALLOW_REACHABLE_SHA1;
984 allow_unadvertised_object_request &= ~ALLOW_REACHABLE_SHA1;
985 } else if (!strcmp("uploadpack.allowanysha1inwant", var)) {
986 if (git_config_bool(var, value))
987 allow_unadvertised_object_request |= ALLOW_ANY_SHA1;
989 allow_unadvertised_object_request &= ~ALLOW_ANY_SHA1;
990 } else if (!strcmp("uploadpack.keepalive", var)) {
991 keepalive = git_config_int(var, value);
994 } else if (current_config_scope() != CONFIG_SCOPE_REPO) {
995 if (!strcmp("uploadpack.packobjectshook", var))
996 return git_config_string(&pack_objects_hook, var, value);
998 return parse_hide_refs_config(var, value, "uploadpack");
1001 void upload_pack(struct upload_pack_options *options)
1003 struct string_list symref = STRING_LIST_INIT_DUP;
1005 stateless_rpc = options->stateless_rpc;
1006 timeout = options->timeout;
1007 daemon_mode = options->daemon_mode;
1009 git_config(upload_pack_config, NULL);
1011 head_ref_namespaced(find_symref, &symref);
1013 if (options->advertise_refs || !stateless_rpc) {
1015 head_ref_namespaced(send_ref, &symref);
1016 for_each_namespaced_ref(send_ref, &symref);
1017 advertise_shallow_grafts(1);
1020 head_ref_namespaced(check_ref, NULL);
1021 for_each_namespaced_ref(check_ref, NULL);
1023 string_list_clear(&symref, 1);
1024 if (options->advertise_refs)
1029 get_common_commits();