upload-pack: pass upload_pack_data to deepen()
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's pass that struct to deepen(), so that this function can use all the fields of the struct. This will be used in followup commits to move static variables into 'upload_pack_data'. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jun 11, 2020 at 14:05 UTC
b1492f22f0c597ff43a790472f50aa114fe4fb73
1 file changed
+11
-14
upload-pack.c
+11
-14
@@ -753,17 +753,16 @@ static void send_unshallow(struct packet_writer *writer,
753
754
static int check_ref(const char *refname_full, const struct object_id *oid,
755
int flag, void *cb_data);
756
-static void deepen(struct packet_writer *writer, int depth, int deepen_relative,
757
- struct object_array *shallows, struct object_array *want_obj)
756
+static void deepen(struct upload_pack_data *data, int depth)
757
{
758
if (depth == INFINITE_DEPTH && !is_repository_shallow(the_repository)) {
759
int i;
760
762
- for (i = 0; i < shallows->nr; i++) {
763
- struct object *object = shallows->objects[i].item;
761
+ for (i = 0; i < data->shallows.nr; i++) {
762
+ struct object *object = data->shallows.objects[i].item;
763
object->flags |= NOT_SHALLOW;
764
}
766
- } else if (deepen_relative) {
765
+ } else if (data->deepen_relative) {
766
struct object_array reachable_shallows = OBJECT_ARRAY_INIT;
767
struct commit_list *result;
768
@@ -774,23 +773,23 @@ static void deepen(struct packet_writer *writer, int depth, int deepen_relative,
773
head_ref_namespaced(check_ref, NULL);
774
for_each_namespaced_ref(check_ref, NULL);
775
777
- get_reachable_list(shallows, &reachable_shallows);
776
+ get_reachable_list(&data->shallows, &reachable_shallows);
777
result = get_shallow_commits(&reachable_shallows,
778
depth + 1,
779
SHALLOW, NOT_SHALLOW);
781
- send_shallow(writer, result);
780
+ send_shallow(&data->writer, result);
781
free_commit_list(result);
782
object_array_clear(&reachable_shallows);
783
} else {
784
struct commit_list *result;
785
787
- result = get_shallow_commits(want_obj, depth,
786
+ result = get_shallow_commits(&data->want_obj, depth,
787
SHALLOW, NOT_SHALLOW);
789
- send_shallow(writer, result);
788
+ send_shallow(&data->writer, result);
789
free_commit_list(result);
790
}
791
793
- send_unshallow(writer, shallows, want_obj);
792
+ send_unshallow(&data->writer, &data->shallows, &data->want_obj);
793
}
794
795
static void deepen_by_rev_list(struct packet_writer *writer, int ac,
@@ -815,8 +814,7 @@ static int send_shallow_list(struct upload_pack_data *data)
814
if (data->depth > 0 && data->deepen_rev_list)
815
die("git upload-pack: deepen and deepen-since (or deepen-not) cannot be used together");
816
if (data->depth > 0) {
818
- deepen(&data->writer, data->depth, data->deepen_relative,
819
- &data->shallows, &data->want_obj);
817
+ deepen(data, data->depth);
818
ret = 1;
819
} else if (data->deepen_rev_list) {
820
struct argv_array av = ARGV_ARRAY_INIT;
@@ -1464,8 +1462,7 @@ static void send_shallow_info(struct upload_pack_data *data)
1462
1463
if (!send_shallow_list(data) &&
1464
is_repository_shallow(the_repository))
1467
- deepen(&data->writer, INFINITE_DEPTH, data->deepen_relative,
1468
- &data->shallows, &data->want_obj);
1465
+ deepen(data, INFINITE_DEPTH);
1466
1467
packet_delim(1);
1468
}