Skip to content

Commit 4e10cf9

Browse files
committed
Revert two "no-done" reverts
Last night I had to make these two emergency reverts, but now we have a better understanding of which part of the topic was broken, let's get rid of the revert to fix it correctly. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 07514c8 commit 4e10cf9

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

builtin/fetch-pack.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ static int transfer_unpack_limit = -1;
1515
static int fetch_unpack_limit = -1;
1616
static int unpack_limit = 100;
1717
static int prefer_ofs_delta = 1;
18+
static int no_done = 0;
1819
static struct fetch_pack_args args = {
1920
/* .uploadpack = */ "git-upload-pack",
2021
};
@@ -250,6 +251,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
250251
const unsigned char *sha1;
251252
unsigned in_vain = 0;
252253
int got_continue = 0;
254+
int got_ready = 0;
253255
struct strbuf req_buf = STRBUF_INIT;
254256
size_t state_len = 0;
255257

@@ -288,6 +290,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
288290
struct strbuf c = STRBUF_INIT;
289291
if (multi_ack == 2) strbuf_addstr(&c, " multi_ack_detailed");
290292
if (multi_ack == 1) strbuf_addstr(&c, " multi_ack");
293+
if (no_done) strbuf_addstr(&c, " no-done");
291294
if (use_sideband == 2) strbuf_addstr(&c, " side-band-64k");
292295
if (use_sideband == 1) strbuf_addstr(&c, " side-band");
293296
if (args.use_thin_pack) strbuf_addstr(&c, " thin-pack");
@@ -406,8 +409,10 @@ static int find_common(int fd[2], unsigned char *result_sha1,
406409
retval = 0;
407410
in_vain = 0;
408411
got_continue = 1;
409-
if (ack == ACK_ready)
412+
if (ack == ACK_ready) {
410413
rev_list = NULL;
414+
got_ready = 1;
415+
}
411416
break;
412417
}
413418
}
@@ -421,8 +426,10 @@ static int find_common(int fd[2], unsigned char *result_sha1,
421426
}
422427
}
423428
done:
424-
packet_buf_write(&req_buf, "done\n");
425-
send_request(fd[1], &req_buf);
429+
if (!got_ready || !no_done) {
430+
packet_buf_write(&req_buf, "done\n");
431+
send_request(fd[1], &req_buf);
432+
}
426433
if (args.verbose)
427434
fprintf(stderr, "done\n");
428435
if (retval != 0) {
@@ -725,6 +732,11 @@ static struct ref *do_fetch_pack(int fd[2],
725732
if (args.verbose)
726733
fprintf(stderr, "Server supports multi_ack_detailed\n");
727734
multi_ack = 2;
735+
if (server_supports("no-done")) {
736+
if (args.verbose)
737+
fprintf(stderr, "Server supports no-done\n");
738+
no_done = 1;
739+
}
728740
}
729741
else if (server_supports("multi_ack")) {
730742
if (args.verbose)

upload-pack.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<
2727
static unsigned long oldest_have;
2828

2929
static int multi_ack, nr_our_refs;
30+
static int no_done;
3031
static int use_thin_pack, use_ofs_delta, use_include_tag;
3132
static int no_progress, daemon_mode;
3233
static int shallow_nr;
@@ -431,6 +432,7 @@ static int get_common_commits(void)
431432
char last_hex[41];
432433
int got_common = 0;
433434
int got_other = 0;
435+
int sent_ready = 0;
434436

435437
save_commit_buffer = 0;
436438

@@ -440,10 +442,17 @@ static int get_common_commits(void)
440442

441443
if (!len) {
442444
if (multi_ack == 2 && got_common
443-
&& !got_other && ok_to_give_up())
445+
&& !got_other && ok_to_give_up()) {
446+
sent_ready = 1;
444447
packet_write(1, "ACK %s ready\n", last_hex);
448+
}
445449
if (have_obj.nr == 0 || multi_ack)
446450
packet_write(1, "NAK\n");
451+
452+
if (no_done && sent_ready) {
453+
packet_write(1, "ACK %s\n", last_hex);
454+
return 0;
455+
}
447456
if (stateless_rpc)
448457
exit(0);
449458
got_common = 0;
@@ -457,9 +466,10 @@ static int get_common_commits(void)
457466
got_other = 1;
458467
if (multi_ack && ok_to_give_up()) {
459468
const char *hex = sha1_to_hex(sha1);
460-
if (multi_ack == 2)
469+
if (multi_ack == 2) {
470+
sent_ready = 1;
461471
packet_write(1, "ACK %s ready\n", hex);
462-
else
472+
} else
463473
packet_write(1, "ACK %s continue\n", hex);
464474
}
465475
break;
@@ -535,6 +545,8 @@ static void receive_needs(void)
535545
multi_ack = 2;
536546
else if (strstr(line+45, "multi_ack"))
537547
multi_ack = 1;
548+
if (strstr(line+45, "no-done"))
549+
no_done = 1;
538550
if (strstr(line+45, "thin-pack"))
539551
use_thin_pack = 1;
540552
if (strstr(line+45, "ofs-delta"))
@@ -628,7 +640,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
628640
{
629641
static const char *capabilities = "multi_ack thin-pack side-band"
630642
" side-band-64k ofs-delta shallow no-progress"
631-
" include-tag multi_ack_detailed";
643+
" include-tag multi_ack_detailed no-done";
632644
struct object *o = parse_object(sha1);
633645

634646
if (!o)

0 commit comments

Comments
 (0)