summaryrefslogtreecommitdiff
path: root/builtin/fetch-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-03-21 04:52:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-03-21 04:53:11 (GMT)
commitc12f5917e4f528b056a8b9ca625397aee97ae1e4 (patch)
treeca8f2f8177e11e021917398886ad63353043f15e /builtin/fetch-pack.c
parent761ecf0bc7b6cddf311f00877c59e6381cdbdeea (diff)
downloadgit-c12f5917e4f528b056a8b9ca625397aee97ae1e4.zip
git-c12f5917e4f528b056a8b9ca625397aee97ae1e4.tar.gz
git-c12f5917e4f528b056a8b9ca625397aee97ae1e4.tar.bz2
fetch-pack: factor out hardcoded handshake window size
The "git fetch" client presents the most recent 32 commits it has to the server and gives a chance to the server to say "ok, we heard enough", and continues reporting what it has in chunks of 32 commits, digging its history down to older commits. Move the hardcoded size of the handshake window outside the code, so that we can tweak it more easily. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Shawn Pearce <spearce@spearce.org>
Diffstat (limited to 'builtin/fetch-pack.c')
-rw-r--r--builtin/fetch-pack.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 59fbda5..1abe624 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -218,11 +218,18 @@ static void send_request(int fd, struct strbuf *buf)
safe_write(fd, buf->buf, buf->len);
}
+#define INITIAL_FLUSH 32
+
+static int next_flush(int count)
+{
+ return INITIAL_FLUSH + count;
+}
+
static int find_common(int fd[2], unsigned char *result_sha1,
struct ref *refs)
{
int fetching;
- int count = 0, flushes = 0, retval;
+ int count = 0, flushes = 0, flush_at = INITIAL_FLUSH, retval;
const unsigned char *sha1;
unsigned in_vain = 0;
int got_continue = 0;
@@ -335,19 +342,20 @@ static int find_common(int fd[2], unsigned char *result_sha1,
if (args.verbose)
fprintf(stderr, "have %s\n", sha1_to_hex(sha1));
in_vain++;
- if (!(31 & ++count)) {
+ if (flush_at <= ++count) {
int ack;
packet_buf_flush(&req_buf);
send_request(fd[1], &req_buf);
strbuf_setlen(&req_buf, state_len);
flushes++;
+ flush_at = next_flush(count);
/*
* We keep one window "ahead" of the other side, and
* will wait for an ACK only on the next one
*/
- if (!args.stateless_rpc && count == 32)
+ if (!args.stateless_rpc && count == INITIAL_FLUSH)
continue;
consume_shallow_list(fd[0]);