upload-pack: move shallow_nr to upload_pack_data
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'shallow_nr' static variable into this struct. It is used by code common to protocol v0 and protocol v2. 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
35b43a107c1a146bef4591ae34fd2040bcd9944c
1 file changed
+12
-12
upload-pack.c
+12
-12
@@ -51,7 +51,6 @@ static timestamp_t oldest_have;
51
/* Allow request of any sha1. Implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1. */
52
#define ALLOW_ANY_SHA1 07
53
static unsigned int allow_unadvertised_object_request;
54
-static int shallow_nr;
54
static struct object_array extra_edge_obj;
55
56
/*
@@ -72,6 +71,7 @@ struct upload_pack_data {
71
int deepen_rev_list;
72
int deepen_relative;
73
int keepalive;
74
+ int shallow_nr;
75
76
unsigned int timeout; /* v0 only */
77
enum {
@@ -192,7 +192,7 @@ static void create_pack_file(struct upload_pack_data *pack_data)
192
pack_objects.use_shell = 1;
193
}
194
195
- if (shallow_nr) {
195
+ if (pack_data->shallow_nr) {
196
argv_array_push(&pack_objects.args, "--shallow-file");
197
argv_array_push(&pack_objects.args, "");
198
}
@@ -202,7 +202,7 @@ static void create_pack_file(struct upload_pack_data *pack_data)
202
argv_array_push(&pack_objects.args, "--thin");
203
204
argv_array_push(&pack_objects.args, "--stdout");
205
- if (shallow_nr)
205
+ if (pack_data->shallow_nr)
206
argv_array_push(&pack_objects.args, "--shallow");
207
if (!pack_data->no_progress)
208
argv_array_push(&pack_objects.args, "--progress");
@@ -233,7 +233,7 @@ static void create_pack_file(struct upload_pack_data *pack_data)
233
234
pipe_fd = xfdopen(pack_objects.in, "w");
235
236
- if (shallow_nr)
236
+ if (pack_data->shallow_nr)
237
for_each_commit_graft(write_one_shallow, pipe_fd);
238
239
for (i = 0; i < pack_data->want_obj.nr; i++)
@@ -700,16 +700,16 @@ error:
700
}
701
}
702
703
-static void send_shallow(struct packet_writer *writer,
703
+static void send_shallow(struct upload_pack_data *data,
704
struct commit_list *result)
705
{
706
while (result) {
707
struct object *object = &result->item->object;
708
if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
709
- packet_writer_write(writer, "shallow %s",
709
+ packet_writer_write(&data->writer, "shallow %s",
710
oid_to_hex(&object->oid));
711
register_shallow(the_repository, &object->oid);
712
- shallow_nr++;
712
+ data->shallow_nr++;
713
}
714
result = result->next;
715
}
@@ -775,7 +775,7 @@ static void deepen(struct upload_pack_data *data, int depth)
775
result = get_shallow_commits(&reachable_shallows,
776
depth + 1,
777
SHALLOW, NOT_SHALLOW);
778
- send_shallow(&data->writer, result);
778
+ send_shallow(data, result);
779
free_commit_list(result);
780
object_array_clear(&reachable_shallows);
781
} else {
@@ -783,7 +783,7 @@ static void deepen(struct upload_pack_data *data, int depth)
783
784
result = get_shallow_commits(&data->want_obj, depth,
785
SHALLOW, NOT_SHALLOW);
786
- send_shallow(&data->writer, result);
786
+ send_shallow(data, result);
787
free_commit_list(result);
788
}
789
@@ -798,7 +798,7 @@ static void deepen_by_rev_list(struct upload_pack_data *data,
798
799
disable_commit_graph(the_repository);
800
result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
801
- send_shallow(&data->writer, result);
801
+ send_shallow(data, result);
802
free_commit_list(result);
803
send_unshallow(data);
804
}
@@ -844,7 +844,7 @@ static int send_shallow_list(struct upload_pack_data *data)
844
}
845
}
846
847
- shallow_nr += data->shallows.nr;
847
+ data->shallow_nr += data->shallows.nr;
848
return ret;
849
}
850
@@ -922,7 +922,7 @@ static void receive_needs(struct upload_pack_data *data,
922
{
923
int has_non_tip = 0;
924
925
- shallow_nr = 0;
925
+ data->shallow_nr = 0;
926
for (;;) {
927
struct object *o;
928
const char *features;