|
14 | 14 | #include "sigchain.h"
|
15 | 15 | #include "version.h"
|
16 | 16 | #include "string-list.h"
|
| 17 | +#include "argv-array.h" |
17 | 18 |
|
18 | 19 | static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<n>] <dir>";
|
19 | 20 |
|
@@ -629,11 +630,25 @@ static void deepen(int depth, const struct object_array *shallows)
|
629 | 630 | packet_flush(1);
|
630 | 631 | }
|
631 | 632 |
|
| 633 | +static void deepen_by_rev_list(int ac, const char **av, |
| 634 | + struct object_array *shallows) |
| 635 | +{ |
| 636 | + struct commit_list *result; |
| 637 | + |
| 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); |
| 642 | + packet_flush(1); |
| 643 | +} |
| 644 | + |
632 | 645 | static void receive_needs(void)
|
633 | 646 | {
|
634 | 647 | struct object_array shallows = OBJECT_ARRAY_INIT;
|
635 | 648 | int depth = 0;
|
636 | 649 | int has_non_tip = 0;
|
| 650 | + unsigned long deepen_since = 0; |
| 651 | + int deepen_rev_list = 0; |
637 | 652 |
|
638 | 653 | shallow_nr = 0;
|
639 | 654 | for (;;) {
|
@@ -670,6 +685,16 @@ static void receive_needs(void)
|
670 | 685 | die("Invalid deepen: %s", line);
|
671 | 686 | continue;
|
672 | 687 | }
|
| 688 | + if (skip_prefix(line, "deepen-since ", &arg)) { |
| 689 | + char *end = NULL; |
| 690 | + deepen_since = strtoul(arg, &end, 0); |
| 691 | + if (!end || *end || !deepen_since || |
| 692 | + /* revisions.c's max_age -1 is special */ |
| 693 | + deepen_since == -1) |
| 694 | + die("Invalid deepen-since: %s", line); |
| 695 | + deepen_rev_list = 1; |
| 696 | + continue; |
| 697 | + } |
673 | 698 | if (!skip_prefix(line, "want ", &arg) ||
|
674 | 699 | get_sha1_hex(arg, sha1_buf))
|
675 | 700 | die("git upload-pack: protocol error, "
|
@@ -721,10 +746,26 @@ static void receive_needs(void)
|
721 | 746 | if (!use_sideband && daemon_mode)
|
722 | 747 | no_progress = 1;
|
723 | 748 |
|
724 |
| - if (depth == 0 && shallows.nr == 0) |
| 749 | + if (depth == 0 && !deepen_rev_list && shallows.nr == 0) |
725 | 750 | return;
|
| 751 | + if (depth > 0 && deepen_rev_list) |
| 752 | + die("git upload-pack: deepen and deepen-since cannot be used together"); |
726 | 753 | if (depth > 0)
|
727 | 754 | deepen(depth, &shallows);
|
| 755 | + else if (deepen_rev_list) { |
| 756 | + struct argv_array av = ARGV_ARRAY_INIT; |
| 757 | + int i; |
| 758 | + |
| 759 | + argv_array_push(&av, "rev-list"); |
| 760 | + if (deepen_since) |
| 761 | + argv_array_pushf(&av, "--max-age=%lu", deepen_since); |
| 762 | + for (i = 0; i < want_obj.nr; i++) { |
| 763 | + struct object *o = want_obj.objects[i].item; |
| 764 | + argv_array_push(&av, oid_to_hex(&o->oid)); |
| 765 | + } |
| 766 | + deepen_by_rev_list(av.argc, av.argv, &shallows); |
| 767 | + argv_array_clear(&av); |
| 768 | + } |
728 | 769 | else
|
729 | 770 | if (shallows.nr > 0) {
|
730 | 771 | int i;
|
@@ -773,7 +814,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
|
773 | 814 | int flag, void *cb_data)
|
774 | 815 | {
|
775 | 816 | static const char *capabilities = "multi_ack thin-pack side-band"
|
776 |
| - " side-band-64k ofs-delta shallow no-progress" |
| 817 | + " side-band-64k ofs-delta shallow deepen-since no-progress" |
777 | 818 | " include-tag multi_ack_detailed";
|
778 | 819 | const char *refname_nons = strip_namespace(refname);
|
779 | 820 | struct object_id peeled;
|
|
0 commit comments