@matheusbsbs / matheus-bagliano / commits / e8498322fa
Fork 0

upload-pack: move 'struct upload_pack_data' around

As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move 'struct upload_pack_data' and the related upload_pack_data_init() and upload_pack_data_clear() functions towards the beginning of the file, so that this struct and its related functions can then be used by upload_pack() in a followup commit. 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 e8498322fa033b6ed5320119a82da0bc50ca18ca
1 file changed +56 -56
upload-pack.c
+56 -56
@@ -72,6 +72,62 @@ static int allow_ref_in_want;
72
73 static int allow_sideband_all;
74
75 +struct upload_pack_data {
76 + struct string_list wanted_refs;
77 + struct object_array want_obj;
78 + struct object_array have_obj;
79 + struct oid_array haves;
80 +
81 + struct object_array shallows;
82 + struct string_list deepen_not;
83 + int depth;
84 + timestamp_t deepen_since;
85 + int deepen_rev_list;
86 + int deepen_relative;
87 +
88 + struct list_objects_filter_options filter_options;
89 +
90 + struct packet_writer writer;
91 +
92 + unsigned stateless_rpc : 1;
93 +
94 + unsigned use_thin_pack : 1;
95 + unsigned use_ofs_delta : 1;
96 + unsigned no_progress : 1;
97 + unsigned use_include_tag : 1;
98 + unsigned done : 1;
99 +};
100 +
101 +static void upload_pack_data_init(struct upload_pack_data *data)
102 +{
103 + struct string_list wanted_refs = STRING_LIST_INIT_DUP;
104 + struct object_array want_obj = OBJECT_ARRAY_INIT;
105 + struct object_array have_obj = OBJECT_ARRAY_INIT;
106 + struct oid_array haves = OID_ARRAY_INIT;
107 + struct object_array shallows = OBJECT_ARRAY_INIT;
108 + struct string_list deepen_not = STRING_LIST_INIT_DUP;
109 +
110 + memset(data, 0, sizeof(*data));
111 + data->wanted_refs = wanted_refs;
112 + data->want_obj = want_obj;
113 + data->have_obj = have_obj;
114 + data->haves = haves;
115 + data->shallows = shallows;
116 + data->deepen_not = deepen_not;
117 + packet_writer_init(&data->writer, 1);
118 +}
119 +
120 +static void upload_pack_data_clear(struct upload_pack_data *data)
121 +{
122 + string_list_clear(&data->wanted_refs, 1);
123 + object_array_clear(&data->want_obj);
124 + object_array_clear(&data->have_obj);
125 + oid_array_clear(&data->haves);
126 + object_array_clear(&data->shallows);
127 + string_list_clear(&data->deepen_not, 0);
128 + list_objects_filter_release(&data->filter_options);
129 +}
130 +
131 static void reset_timeout(void)
132 {
133 alarm(timeout);
@@ -1130,62 +1186,6 @@ void upload_pack(struct upload_pack_options *options)
1186 list_objects_filter_release(&filter_options);
1187 }
1188
1133 -struct upload_pack_data {
1134 - struct string_list wanted_refs;
1135 - struct object_array want_obj;
1136 - struct object_array have_obj;
1137 - struct oid_array haves;
1138 -
1139 - struct object_array shallows;
1140 - struct string_list deepen_not;
1141 - int depth;
1142 - timestamp_t deepen_since;
1143 - int deepen_rev_list;
1144 - int deepen_relative;
1145 -
1146 - struct list_objects_filter_options filter_options;
1147 -
1148 - struct packet_writer writer;
1149 -
1150 - unsigned stateless_rpc : 1;
1151 -
1152 - unsigned use_thin_pack : 1;
1153 - unsigned use_ofs_delta : 1;
1154 - unsigned no_progress : 1;
1155 - unsigned use_include_tag : 1;
1156 - unsigned done : 1;
1157 -};
1158 -
1159 -static void upload_pack_data_init(struct upload_pack_data *data)
1160 -{
1161 - struct string_list wanted_refs = STRING_LIST_INIT_DUP;
1162 - struct object_array want_obj = OBJECT_ARRAY_INIT;
1163 - struct object_array have_obj = OBJECT_ARRAY_INIT;
1164 - struct oid_array haves = OID_ARRAY_INIT;
1165 - struct object_array shallows = OBJECT_ARRAY_INIT;
1166 - struct string_list deepen_not = STRING_LIST_INIT_DUP;
1167 -
1168 - memset(data, 0, sizeof(*data));
1169 - data->wanted_refs = wanted_refs;
1170 - data->want_obj = want_obj;
1171 - data->have_obj = have_obj;
1172 - data->haves = haves;
1173 - data->shallows = shallows;
1174 - data->deepen_not = deepen_not;
1175 - packet_writer_init(&data->writer, 1);
1176 -}
1177 -
1178 -static void upload_pack_data_clear(struct upload_pack_data *data)
1179 -{
1180 - string_list_clear(&data->wanted_refs, 1);
1181 - object_array_clear(&data->want_obj);
1182 - object_array_clear(&data->have_obj);
1183 - oid_array_clear(&data->haves);
1184 - object_array_clear(&data->shallows);
1185 - string_list_clear(&data->deepen_not, 0);
1186 - list_objects_filter_release(&data->filter_options);
1187 -}
1188 -
1189 static int parse_want(struct packet_writer *writer, const char *line,
1190 struct object_array *want_obj)
1191 {