Skip to content

Commit 438528f

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ace028 commit 438528f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

upload-pack.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static int allow_ref_in_want;
7373
static int allow_sideband_all;
7474

7575
struct upload_pack_data {
76+
struct string_list symref;
7677
struct string_list wanted_refs;
7778
struct object_array want_obj;
7879
struct object_array have_obj;
@@ -100,6 +101,7 @@ struct upload_pack_data {
100101

101102
static void upload_pack_data_init(struct upload_pack_data *data)
102103
{
104+
struct string_list symref = STRING_LIST_INIT_DUP;
103105
struct string_list wanted_refs = STRING_LIST_INIT_DUP;
104106
struct object_array want_obj = OBJECT_ARRAY_INIT;
105107
struct object_array have_obj = OBJECT_ARRAY_INIT;
@@ -108,6 +110,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
108110
struct string_list deepen_not = STRING_LIST_INIT_DUP;
109111

110112
memset(data, 0, sizeof(*data));
113+
data->symref = symref;
111114
data->wanted_refs = wanted_refs;
112115
data->want_obj = want_obj;
113116
data->have_obj = have_obj;
@@ -119,6 +122,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
119122

120123
static void upload_pack_data_clear(struct upload_pack_data *data)
121124
{
125+
string_list_clear(&data->symref, 1);
122126
string_list_clear(&data->wanted_refs, 1);
123127
object_array_clear(&data->want_obj);
124128
object_array_clear(&data->have_obj);
@@ -1142,7 +1146,6 @@ static int upload_pack_config(const char *var, const char *value, void *unused)
11421146

11431147
void upload_pack(struct upload_pack_options *options)
11441148
{
1145-
struct string_list symref = STRING_LIST_INIT_DUP;
11461149
struct packet_reader reader;
11471150
struct upload_pack_data data;
11481151

@@ -1154,19 +1157,18 @@ void upload_pack(struct upload_pack_options *options)
11541157

11551158
upload_pack_data_init(&data);
11561159

1157-
head_ref_namespaced(find_symref, &symref);
1160+
head_ref_namespaced(find_symref, &data.symref);
11581161

11591162
if (options->advertise_refs || !stateless_rpc) {
11601163
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);
11631166
advertise_shallow_grafts(1);
11641167
packet_flush(1);
11651168
} else {
11661169
head_ref_namespaced(check_ref, NULL);
11671170
for_each_namespaced_ref(check_ref, NULL);
11681171
}
1169-
string_list_clear(&symref, 1);
11701172

11711173
if (!options->advertise_refs) {
11721174
packet_reader_init(&reader, 0, NULL, 0,

0 commit comments

Comments
 (0)