Skip to content

Commit ebf8ebc

Browse files
chriscoolgitster
authored andcommitted
upload-pack: use 'struct upload_pack_data' in upload_pack()
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's use 'struct upload_pack_data' in upload_pack(). This will make it possible in followup commits to remove a lot of static variables and local variables that have the same name and purpose as fields in 'struct upload_pack_data'. This will also make upload_pack() work in a more similar way as upload_pack_v2(). Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e849832 commit ebf8ebc

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

upload-pack.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,18 +1144,17 @@ static int upload_pack_config(const char *var, const char *value, void *unused)
11441144
void upload_pack(struct upload_pack_options *options)
11451145
{
11461146
struct string_list symref = STRING_LIST_INIT_DUP;
1147-
struct object_array want_obj = OBJECT_ARRAY_INIT;
11481147
struct packet_reader reader;
1149-
struct list_objects_filter_options filter_options;
1148+
struct upload_pack_data data;
11501149

11511150
stateless_rpc = options->stateless_rpc;
11521151
timeout = options->timeout;
11531152
daemon_mode = options->daemon_mode;
11541153

1155-
memset(&filter_options, 0, sizeof(filter_options));
1156-
11571154
git_config(upload_pack_config, NULL);
11581155

1156+
upload_pack_data_init(&data);
1157+
11591158
head_ref_namespaced(find_symref, &symref);
11601159

11611160
if (options->advertise_refs || !stateless_rpc) {
@@ -1169,21 +1168,24 @@ void upload_pack(struct upload_pack_options *options)
11691168
for_each_namespaced_ref(check_ref, NULL);
11701169
}
11711170
string_list_clear(&symref, 1);
1172-
if (options->advertise_refs)
1173-
return;
11741171

1175-
packet_reader_init(&reader, 0, NULL, 0,
1176-
PACKET_READ_CHOMP_NEWLINE |
1177-
PACKET_READ_DIE_ON_ERR_PACKET);
1172+
if (!options->advertise_refs) {
1173+
packet_reader_init(&reader, 0, NULL, 0,
1174+
PACKET_READ_CHOMP_NEWLINE |
1175+
PACKET_READ_DIE_ON_ERR_PACKET);
11781176

1179-
receive_needs(&reader, &want_obj, &filter_options);
1180-
if (want_obj.nr) {
1181-
struct object_array have_obj = OBJECT_ARRAY_INIT;
1182-
get_common_commits(&reader, &have_obj, &want_obj);
1183-
create_pack_file(&have_obj, &want_obj, &filter_options);
1177+
receive_needs(&reader, &data.want_obj, &data.filter_options);
1178+
if (data.want_obj.nr) {
1179+
get_common_commits(&reader,
1180+
&data.have_obj,
1181+
&data.want_obj);
1182+
create_pack_file(&data.have_obj,
1183+
&data.want_obj,
1184+
&data.filter_options);
1185+
}
11841186
}
11851187

1186-
list_objects_filter_release(&filter_options);
1188+
upload_pack_data_clear(&data);
11871189
}
11881190

11891191
static int parse_want(struct packet_writer *writer, const char *line,

0 commit comments

Comments
 (0)