upload-pack: move symref to upload_pack_data
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, we are passing around that struct to many functions, so let's also pass 'struct string_list symref' around at the same time by moving it from a local variable in upload_pack() into a field of 'struct upload_pack_data'. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
May 15, 2020 at 12:04 UTC
438528f611d7bf199d68584e514a304fa4153fbb
1 file changed
+7
-5
upload-pack.c
+7
-5
@@ -73,6 +73,7 @@ static int allow_ref_in_want;
73
static int allow_sideband_all;
74
75
struct upload_pack_data {
76
+ struct string_list symref;
77
struct string_list wanted_refs;
78
struct object_array want_obj;
79
struct object_array have_obj;
@@ -100,6 +101,7 @@ struct upload_pack_data {
101
102
static void upload_pack_data_init(struct upload_pack_data *data)
103
{
104
+ struct string_list symref = STRING_LIST_INIT_DUP;
105
struct string_list wanted_refs = STRING_LIST_INIT_DUP;
106
struct object_array want_obj = OBJECT_ARRAY_INIT;
107
struct object_array have_obj = OBJECT_ARRAY_INIT;
@@ -108,6 +110,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
110
struct string_list deepen_not = STRING_LIST_INIT_DUP;
111
112
memset(data, 0, sizeof(*data));
113
+ data->symref = symref;
114
data->wanted_refs = wanted_refs;
115
data->want_obj = want_obj;
116
data->have_obj = have_obj;
@@ -119,6 +122,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
122
123
static void upload_pack_data_clear(struct upload_pack_data *data)
124
{
125
+ string_list_clear(&data->symref, 1);
126
string_list_clear(&data->wanted_refs, 1);
127
object_array_clear(&data->want_obj);
128
object_array_clear(&data->have_obj);
@@ -1142,7 +1146,6 @@ static int upload_pack_config(const char *var, const char *value, void *unused)
1146
1147
void upload_pack(struct upload_pack_options *options)
1148
{
1145
- struct string_list symref = STRING_LIST_INIT_DUP;
1149
struct packet_reader reader;
1150
struct upload_pack_data data;
1151
@@ -1154,19 +1157,18 @@ void upload_pack(struct upload_pack_options *options)
1157
1158
upload_pack_data_init(&data);
1159
1157
- head_ref_namespaced(find_symref, &symref);
1160
+ head_ref_namespaced(find_symref, &data.symref);
1161
1162
if (options->advertise_refs || !stateless_rpc) {
1163
reset_timeout();
1161
- head_ref_namespaced(send_ref, &symref);
1162
- for_each_namespaced_ref(send_ref, &symref);
1164
+ head_ref_namespaced(send_ref, &data.symref);
1165
+ for_each_namespaced_ref(send_ref, &data.symref);
1166
advertise_shallow_grafts(1);
1167
packet_flush(1);
1168
} else {
1169
head_ref_namespaced(check_ref, NULL);
1170
for_each_namespaced_ref(check_ref, NULL);
1171
}
1169
- string_list_clear(&symref, 1);
1172
1173
if (!options->advertise_refs) {
1174
packet_reader_init(&reader, 0, NULL, 0,