Skip to content

Commit

Permalink
upload-pack: move symref to upload_pack_data
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
chriscool authored and gitster committed May 18, 2020
1 parent 4ace028 commit 438528f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions upload-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ static int allow_ref_in_want;
static int allow_sideband_all;

struct upload_pack_data {
struct string_list symref;
struct string_list wanted_refs;
struct object_array want_obj;
struct object_array have_obj;
Expand Down Expand Up @@ -100,6 +101,7 @@ struct upload_pack_data {

static void upload_pack_data_init(struct upload_pack_data *data)
{
struct string_list symref = STRING_LIST_INIT_DUP;
struct string_list wanted_refs = STRING_LIST_INIT_DUP;
struct object_array want_obj = OBJECT_ARRAY_INIT;
struct object_array have_obj = OBJECT_ARRAY_INIT;
Expand All @@ -108,6 +110,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
struct string_list deepen_not = STRING_LIST_INIT_DUP;

memset(data, 0, sizeof(*data));
data->symref = symref;
data->wanted_refs = wanted_refs;
data->want_obj = want_obj;
data->have_obj = have_obj;
Expand All @@ -119,6 +122,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)

static void upload_pack_data_clear(struct upload_pack_data *data)
{
string_list_clear(&data->symref, 1);
string_list_clear(&data->wanted_refs, 1);
object_array_clear(&data->want_obj);
object_array_clear(&data->have_obj);
Expand Down Expand Up @@ -1142,7 +1146,6 @@ static int upload_pack_config(const char *var, const char *value, void *unused)

void upload_pack(struct upload_pack_options *options)
{
struct string_list symref = STRING_LIST_INIT_DUP;
struct packet_reader reader;
struct upload_pack_data data;

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

upload_pack_data_init(&data);

head_ref_namespaced(find_symref, &symref);
head_ref_namespaced(find_symref, &data.symref);

if (options->advertise_refs || !stateless_rpc) {
reset_timeout();
head_ref_namespaced(send_ref, &symref);
for_each_namespaced_ref(send_ref, &symref);
head_ref_namespaced(send_ref, &data.symref);
for_each_namespaced_ref(send_ref, &data.symref);
advertise_shallow_grafts(1);
packet_flush(1);
} else {
head_ref_namespaced(check_ref, NULL);
for_each_namespaced_ref(check_ref, NULL);
}
string_list_clear(&symref, 1);

if (!options->advertise_refs) {
packet_reader_init(&reader, 0, NULL, 0,
Expand Down

0 comments on commit 438528f

Please sign in to comment.