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

upload-pack: actually use some upload_pack_data bitfields

As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's actually start using some bitfields of that struct. These bitfields were introduced in 3145ea957d ("upload-pack: introduce fetch server command", 2018-03-15), but were never used. We could instead have just removed the following bitfields from the struct: unsigned use_thin_pack : 1; unsigned use_ofs_delta : 1; unsigned no_progress : 1; unsigned use_include_tag : 1; but using them makes it possible to remove a number of static variables with the same name and purpose from 'upload-pack.c'. This is a behavior change, as we accidentally used to let values in those bitfields propagate from one v2 "fetch" command to another for ssh/git/file connections (but not for http). That's fixing a bug, but one nobody is likely to see, because it would imply the client sending different capabilities for each request. Helped-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jun 4, 2020 at 19:54 UTC b5a2068cb1f879b8bff2bfbf99304091d03ce3af
1 file changed +14 -15
upload-pack.c
+14 -15
@@ -46,8 +46,7 @@ static timestamp_t oldest_have;
46
47 static int multi_ack;
48 static int no_done;
49 -static int use_thin_pack, use_ofs_delta, use_include_tag;
50 -static int no_progress, daemon_mode;
49 +static int daemon_mode;
50 /* Allow specifying sha1 if it is a ref tip. */
51 #define ALLOW_TIP_SHA1 01
52 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
@@ -186,17 +185,17 @@ static void create_pack_file(struct upload_pack_data *pack_data)
185 }
186 argv_array_push(&pack_objects.args, "pack-objects");
187 argv_array_push(&pack_objects.args, "--revs");
189 - if (use_thin_pack)
188 + if (pack_data->use_thin_pack)
189 argv_array_push(&pack_objects.args, "--thin");
190
191 argv_array_push(&pack_objects.args, "--stdout");
192 if (shallow_nr)
193 argv_array_push(&pack_objects.args, "--shallow");
195 - if (!no_progress)
194 + if (!pack_data->no_progress)
195 argv_array_push(&pack_objects.args, "--progress");
197 - if (use_ofs_delta)
196 + if (pack_data->use_ofs_delta)
197 argv_array_push(&pack_objects.args, "--delta-base-offset");
199 - if (use_include_tag)
198 + if (pack_data->use_include_tag)
199 argv_array_push(&pack_objects.args, "--include-tag");
200 if (pack_data->filter_options.choice) {
201 const char *spec =
@@ -955,17 +954,17 @@ static void receive_needs(struct upload_pack_data *data,
954 if (parse_feature_request(features, "no-done"))
955 no_done = 1;
956 if (parse_feature_request(features, "thin-pack"))
958 - use_thin_pack = 1;
957 + data->use_thin_pack = 1;
958 if (parse_feature_request(features, "ofs-delta"))
960 - use_ofs_delta = 1;
959 + data->use_ofs_delta = 1;
960 if (parse_feature_request(features, "side-band-64k"))
961 use_sideband = LARGE_PACKET_MAX;
962 else if (parse_feature_request(features, "side-band"))
963 use_sideband = DEFAULT_PACKET_MAX;
964 if (parse_feature_request(features, "no-progress"))
966 - no_progress = 1;
965 + data->no_progress = 1;
966 if (parse_feature_request(features, "include-tag"))
968 - use_include_tag = 1;
967 + data->use_include_tag = 1;
968 if (allow_filter && parse_feature_request(features, "filter"))
969 filter_capability_requested = 1;
970
@@ -997,7 +996,7 @@ static void receive_needs(struct upload_pack_data *data,
996 check_non_tip(data);
997
998 if (!use_sideband && daemon_mode)
1000 - no_progress = 1;
999 + data->no_progress = 1;
1000
1001 if (data->depth == 0 && !data->deepen_rev_list && data->shallows.nr == 0)
1002 return;
@@ -1279,19 +1278,19 @@ static void process_args(struct packet_reader *request,
1278
1279 /* process args like thin-pack */
1280 if (!strcmp(arg, "thin-pack")) {
1282 - use_thin_pack = 1;
1281 + data->use_thin_pack = 1;
1282 continue;
1283 }
1284 if (!strcmp(arg, "ofs-delta")) {
1286 - use_ofs_delta = 1;
1285 + data->use_ofs_delta = 1;
1286 continue;
1287 }
1288 if (!strcmp(arg, "no-progress")) {
1290 - no_progress = 1;
1289 + data->no_progress = 1;
1290 continue;
1291 }
1292 if (!strcmp(arg, "include-tag")) {
1294 - use_include_tag = 1;
1293 + data->use_include_tag = 1;
1294 continue;
1295 }
1296 if (!strcmp(arg, "done")) {