Skip to content

Commit

Permalink
upload-pack: actually use some upload_pack_data bitfields
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, let's actually start using some bitfields of
that struct, which were previously unused.

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.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed May 27, 2020
1 parent 7a51676 commit 6c47e1f
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions upload-pack.c
Expand Up @@ -46,8 +46,7 @@ static timestamp_t oldest_have;

static int multi_ack;
static int no_done;
static int use_thin_pack, use_ofs_delta, use_include_tag;
static int no_progress, daemon_mode;
static int daemon_mode;
/* Allow specifying sha1 if it is a ref tip. */
#define ALLOW_TIP_SHA1 01
/* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
Expand Down Expand Up @@ -186,17 +185,17 @@ static void create_pack_file(struct upload_pack_data *pack_data)
}
argv_array_push(&pack_objects.args, "pack-objects");
argv_array_push(&pack_objects.args, "--revs");
if (use_thin_pack)
if (pack_data->use_thin_pack)
argv_array_push(&pack_objects.args, "--thin");

argv_array_push(&pack_objects.args, "--stdout");
if (shallow_nr)
argv_array_push(&pack_objects.args, "--shallow");
if (!no_progress)
if (!pack_data->no_progress)
argv_array_push(&pack_objects.args, "--progress");
if (use_ofs_delta)
if (pack_data->use_ofs_delta)
argv_array_push(&pack_objects.args, "--delta-base-offset");
if (use_include_tag)
if (pack_data->use_include_tag)
argv_array_push(&pack_objects.args, "--include-tag");
if (pack_data->filter_options.choice) {
const char *spec =
Expand Down Expand Up @@ -955,17 +954,17 @@ static void receive_needs(struct upload_pack_data *data,
if (parse_feature_request(features, "no-done"))
no_done = 1;
if (parse_feature_request(features, "thin-pack"))
use_thin_pack = 1;
data->use_thin_pack = 1;
if (parse_feature_request(features, "ofs-delta"))
use_ofs_delta = 1;
data->use_ofs_delta = 1;
if (parse_feature_request(features, "side-band-64k"))
use_sideband = LARGE_PACKET_MAX;
else if (parse_feature_request(features, "side-band"))
use_sideband = DEFAULT_PACKET_MAX;
if (parse_feature_request(features, "no-progress"))
no_progress = 1;
data->no_progress = 1;
if (parse_feature_request(features, "include-tag"))
use_include_tag = 1;
data->use_include_tag = 1;
if (allow_filter && parse_feature_request(features, "filter"))
filter_capability_requested = 1;

Expand Down Expand Up @@ -997,7 +996,7 @@ static void receive_needs(struct upload_pack_data *data,
check_non_tip(data);

if (!use_sideband && daemon_mode)
no_progress = 1;
data->no_progress = 1;

if (data->depth == 0 && !data->deepen_rev_list && data->shallows.nr == 0)
return;
Expand Down Expand Up @@ -1279,19 +1278,19 @@ static void process_args(struct packet_reader *request,

/* process args like thin-pack */
if (!strcmp(arg, "thin-pack")) {
use_thin_pack = 1;
data->use_thin_pack = 1;
continue;
}
if (!strcmp(arg, "ofs-delta")) {
use_ofs_delta = 1;
data->use_ofs_delta = 1;
continue;
}
if (!strcmp(arg, "no-progress")) {
no_progress = 1;
data->no_progress = 1;
continue;
}
if (!strcmp(arg, "include-tag")) {
use_include_tag = 1;
data->use_include_tag = 1;
continue;
}
if (!strcmp(arg, "done")) {
Expand Down

0 comments on commit 6c47e1f

Please sign in to comment.