Skip to content

Commit 35b43a1

Browse files
chriscoolgitster
authored andcommitted
upload-pack: move shallow_nr to upload_pack_data
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'shallow_nr' static variable into this struct. It is used by code common to protocol v0 and protocol v2. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 329f996 commit 35b43a1

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

upload-pack.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ static timestamp_t oldest_have;
5151
/* Allow request of any sha1. Implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1. */
5252
#define ALLOW_ANY_SHA1 07
5353
static unsigned int allow_unadvertised_object_request;
54-
static int shallow_nr;
5554
static struct object_array extra_edge_obj;
5655

5756
/*
@@ -72,6 +71,7 @@ struct upload_pack_data {
7271
int deepen_rev_list;
7372
int deepen_relative;
7473
int keepalive;
74+
int shallow_nr;
7575

7676
unsigned int timeout; /* v0 only */
7777
enum {
@@ -192,7 +192,7 @@ static void create_pack_file(struct upload_pack_data *pack_data)
192192
pack_objects.use_shell = 1;
193193
}
194194

195-
if (shallow_nr) {
195+
if (pack_data->shallow_nr) {
196196
argv_array_push(&pack_objects.args, "--shallow-file");
197197
argv_array_push(&pack_objects.args, "");
198198
}
@@ -202,7 +202,7 @@ static void create_pack_file(struct upload_pack_data *pack_data)
202202
argv_array_push(&pack_objects.args, "--thin");
203203

204204
argv_array_push(&pack_objects.args, "--stdout");
205-
if (shallow_nr)
205+
if (pack_data->shallow_nr)
206206
argv_array_push(&pack_objects.args, "--shallow");
207207
if (!pack_data->no_progress)
208208
argv_array_push(&pack_objects.args, "--progress");
@@ -233,7 +233,7 @@ static void create_pack_file(struct upload_pack_data *pack_data)
233233

234234
pipe_fd = xfdopen(pack_objects.in, "w");
235235

236-
if (shallow_nr)
236+
if (pack_data->shallow_nr)
237237
for_each_commit_graft(write_one_shallow, pipe_fd);
238238

239239
for (i = 0; i < pack_data->want_obj.nr; i++)
@@ -700,16 +700,16 @@ static void check_non_tip(struct upload_pack_data *data)
700700
}
701701
}
702702

703-
static void send_shallow(struct packet_writer *writer,
703+
static void send_shallow(struct upload_pack_data *data,
704704
struct commit_list *result)
705705
{
706706
while (result) {
707707
struct object *object = &result->item->object;
708708
if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
709-
packet_writer_write(writer, "shallow %s",
709+
packet_writer_write(&data->writer, "shallow %s",
710710
oid_to_hex(&object->oid));
711711
register_shallow(the_repository, &object->oid);
712-
shallow_nr++;
712+
data->shallow_nr++;
713713
}
714714
result = result->next;
715715
}
@@ -775,15 +775,15 @@ static void deepen(struct upload_pack_data *data, int depth)
775775
result = get_shallow_commits(&reachable_shallows,
776776
depth + 1,
777777
SHALLOW, NOT_SHALLOW);
778-
send_shallow(&data->writer, result);
778+
send_shallow(data, result);
779779
free_commit_list(result);
780780
object_array_clear(&reachable_shallows);
781781
} else {
782782
struct commit_list *result;
783783

784784
result = get_shallow_commits(&data->want_obj, depth,
785785
SHALLOW, NOT_SHALLOW);
786-
send_shallow(&data->writer, result);
786+
send_shallow(data, result);
787787
free_commit_list(result);
788788
}
789789

@@ -798,7 +798,7 @@ static void deepen_by_rev_list(struct upload_pack_data *data,
798798

799799
disable_commit_graph(the_repository);
800800
result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
801-
send_shallow(&data->writer, result);
801+
send_shallow(data, result);
802802
free_commit_list(result);
803803
send_unshallow(data);
804804
}
@@ -844,7 +844,7 @@ static int send_shallow_list(struct upload_pack_data *data)
844844
}
845845
}
846846

847-
shallow_nr += data->shallows.nr;
847+
data->shallow_nr += data->shallows.nr;
848848
return ret;
849849
}
850850

@@ -922,7 +922,7 @@ static void receive_needs(struct upload_pack_data *data,
922922
{
923923
int has_non_tip = 0;
924924

925-
shallow_nr = 0;
925+
data->shallow_nr = 0;
926926
for (;;) {
927927
struct object *o;
928928
const char *features;

0 commit comments

Comments
 (0)