upload-pack: pass upload_pack_data to get_common_commits()
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's pass 'struct upload_pack_data' to get_common_commits(), so that this function and the functions it calls can use all the fields of that struct in followup commits. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
ebf8ebcc56
commit
0797769505
|
@ -414,9 +414,8 @@ static int ok_to_give_up(const struct object_array *have_obj,
|
||||||
min_generation);
|
min_generation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_common_commits(struct packet_reader *reader,
|
static int get_common_commits(struct upload_pack_data *data,
|
||||||
struct object_array *have_obj,
|
struct packet_reader *reader)
|
||||||
struct object_array *want_obj)
|
|
||||||
{
|
{
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
char last_hex[GIT_MAX_HEXSZ + 1];
|
char last_hex[GIT_MAX_HEXSZ + 1];
|
||||||
|
@ -432,12 +431,14 @@ static int get_common_commits(struct packet_reader *reader,
|
||||||
reset_timeout();
|
reset_timeout();
|
||||||
|
|
||||||
if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
|
if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
|
||||||
if (multi_ack == 2 && got_common
|
if (multi_ack == 2
|
||||||
&& !got_other && ok_to_give_up(have_obj, want_obj)) {
|
&& got_common
|
||||||
|
&& !got_other
|
||||||
|
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
|
||||||
sent_ready = 1;
|
sent_ready = 1;
|
||||||
packet_write_fmt(1, "ACK %s ready\n", last_hex);
|
packet_write_fmt(1, "ACK %s ready\n", last_hex);
|
||||||
}
|
}
|
||||||
if (have_obj->nr == 0 || multi_ack)
|
if (data->have_obj.nr == 0 || multi_ack)
|
||||||
packet_write_fmt(1, "NAK\n");
|
packet_write_fmt(1, "NAK\n");
|
||||||
|
|
||||||
if (no_done && sent_ready) {
|
if (no_done && sent_ready) {
|
||||||
|
@ -451,10 +452,11 @@ static int get_common_commits(struct packet_reader *reader,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (skip_prefix(reader->line, "have ", &arg)) {
|
if (skip_prefix(reader->line, "have ", &arg)) {
|
||||||
switch (got_oid(arg, &oid, have_obj)) {
|
switch (got_oid(arg, &oid, &data->have_obj)) {
|
||||||
case -1: /* they have what we do not */
|
case -1: /* they have what we do not */
|
||||||
got_other = 1;
|
got_other = 1;
|
||||||
if (multi_ack && ok_to_give_up(have_obj, want_obj)) {
|
if (multi_ack
|
||||||
|
&& ok_to_give_up(&data->have_obj, &data->want_obj)) {
|
||||||
const char *hex = oid_to_hex(&oid);
|
const char *hex = oid_to_hex(&oid);
|
||||||
if (multi_ack == 2) {
|
if (multi_ack == 2) {
|
||||||
sent_ready = 1;
|
sent_ready = 1;
|
||||||
|
@ -470,14 +472,14 @@ static int get_common_commits(struct packet_reader *reader,
|
||||||
packet_write_fmt(1, "ACK %s common\n", last_hex);
|
packet_write_fmt(1, "ACK %s common\n", last_hex);
|
||||||
else if (multi_ack)
|
else if (multi_ack)
|
||||||
packet_write_fmt(1, "ACK %s continue\n", last_hex);
|
packet_write_fmt(1, "ACK %s continue\n", last_hex);
|
||||||
else if (have_obj->nr == 1)
|
else if (data->have_obj.nr == 1)
|
||||||
packet_write_fmt(1, "ACK %s\n", last_hex);
|
packet_write_fmt(1, "ACK %s\n", last_hex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(reader->line, "done")) {
|
if (!strcmp(reader->line, "done")) {
|
||||||
if (have_obj->nr > 0) {
|
if (data->have_obj.nr > 0) {
|
||||||
if (multi_ack)
|
if (multi_ack)
|
||||||
packet_write_fmt(1, "ACK %s\n", last_hex);
|
packet_write_fmt(1, "ACK %s\n", last_hex);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1176,9 +1178,7 @@ void upload_pack(struct upload_pack_options *options)
|
||||||
|
|
||||||
receive_needs(&reader, &data.want_obj, &data.filter_options);
|
receive_needs(&reader, &data.want_obj, &data.filter_options);
|
||||||
if (data.want_obj.nr) {
|
if (data.want_obj.nr) {
|
||||||
get_common_commits(&reader,
|
get_common_commits(&data, &reader);
|
||||||
&data.have_obj,
|
|
||||||
&data.want_obj);
|
|
||||||
create_pack_file(&data.have_obj,
|
create_pack_file(&data.have_obj,
|
||||||
&data.want_obj,
|
&data.want_obj,
|
||||||
&data.filter_options);
|
&data.filter_options);
|
||||||
|
|
Loading…
Reference in New Issue