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 <gitster@pobox.com>
Junio C Hamano committed
Mar 29, 2011 at 12:29 UTC
4e10cf9a17467c08754b36683c240fbab69156de
2 files changed
+31
-7
builtin/fetch-pack.c
+15
-3
@@ -15,6 +15,7 @@ static int transfer_unpack_limit = -1;
15
static int fetch_unpack_limit = -1;
16
static int unpack_limit = 100;
17
static int prefer_ofs_delta = 1;
18
+static int no_done = 0;
19
static struct fetch_pack_args args = {
20
/* .uploadpack = */ "git-upload-pack",
21
};
@@ -250,6 +251,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
251
const unsigned char *sha1;
252
unsigned in_vain = 0;
253
int got_continue = 0;
254
+ int got_ready = 0;
255
struct strbuf req_buf = STRBUF_INIT;
256
size_t state_len = 0;
257
@@ -288,6 +290,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
290
struct strbuf c = STRBUF_INIT;
291
if (multi_ack == 2) strbuf_addstr(&c, " multi_ack_detailed");
292
if (multi_ack == 1) strbuf_addstr(&c, " multi_ack");
293
+ if (no_done) strbuf_addstr(&c, " no-done");
294
if (use_sideband == 2) strbuf_addstr(&c, " side-band-64k");
295
if (use_sideband == 1) strbuf_addstr(&c, " side-band");
296
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,
409
retval = 0;
410
in_vain = 0;
411
got_continue = 1;
409
- if (ack == ACK_ready)
412
+ if (ack == ACK_ready) {
413
rev_list = NULL;
414
+ got_ready = 1;
415
+ }
416
break;
417
}
418
}
@@ -421,8 +426,10 @@ static int find_common(int fd[2], unsigned char *result_sha1,
426
}
427
}
428
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
+ }
433
if (args.verbose)
434
fprintf(stderr, "done\n");
435
if (retval != 0) {
@@ -725,6 +732,11 @@ static struct ref *do_fetch_pack(int fd[2],
732
if (args.verbose)
733
fprintf(stderr, "Server supports multi_ack_detailed\n");
734
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
+ }
740
}
741
else if (server_supports("multi_ack")) {
742
if (args.verbose)
upload-pack.c
+16
-4
@@ -27,6 +27,7 @@ static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<
27
static unsigned long oldest_have;
28
29
static int multi_ack, nr_our_refs;
30
+static int no_done;
31
static int use_thin_pack, use_ofs_delta, use_include_tag;
32
static int no_progress, daemon_mode;
33
static int shallow_nr;
@@ -431,6 +432,7 @@ static int get_common_commits(void)
432
char last_hex[41];
433
int got_common = 0;
434
int got_other = 0;
435
+ int sent_ready = 0;
436
437
save_commit_buffer = 0;
438
@@ -440,10 +442,17 @@ static int get_common_commits(void)
442
443
if (!len) {
444
if (multi_ack == 2 && got_common
443
- && !got_other && ok_to_give_up())
445
+ && !got_other && ok_to_give_up()) {
446
+ sent_ready = 1;
447
packet_write(1, "ACK %s ready\n", last_hex);
448
+ }
449
if (have_obj.nr == 0 || multi_ack)
450
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
+ }
456
if (stateless_rpc)
457
exit(0);
458
got_common = 0;
@@ -457,9 +466,10 @@ static int get_common_commits(void)
466
got_other = 1;
467
if (multi_ack && ok_to_give_up()) {
468
const char *hex = sha1_to_hex(sha1);
460
- if (multi_ack == 2)
469
+ if (multi_ack == 2) {
470
+ sent_ready = 1;
471
packet_write(1, "ACK %s ready\n", hex);
462
- else
472
+ } else
473
packet_write(1, "ACK %s continue\n", hex);
474
}
475
break;
@@ -535,6 +545,8 @@ static void receive_needs(void)
545
multi_ack = 2;
546
else if (strstr(line+45, "multi_ack"))
547
multi_ack = 1;
548
+ if (strstr(line+45, "no-done"))
549
+ no_done = 1;
550
if (strstr(line+45, "thin-pack"))
551
use_thin_pack = 1;
552
if (strstr(line+45, "ofs-delta"))
@@ -628,7 +640,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
640
{
641
static const char *capabilities = "multi_ack thin-pack side-band"
642
" side-band-64k ofs-delta shallow no-progress"
631
- " include-tag multi_ack_detailed";
643
+ " include-tag multi_ack_detailed no-done";
644
struct object *o = parse_object(sha1);
645
646
if (!o)