Revert two "no-done" reverts
[gitweb.git] / builtin / fetch-pack.c
index b4f34a2cf93a8e0579ea183b644f558807df47e5..bf9990ce15bf582293535606467fb209457bcfe1 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "refs.h"
 #include "pkt-line.h"
 #include "commit.h"
@@ -9,6 +9,7 @@
 #include "fetch-pack.h"
 #include "remote.h"
 #include "run-command.h"
+#include "transport.h"
 
 static int transfer_unpack_limit = -1;
 static int fetch_unpack_limit = -1;
@@ -218,12 +219,24 @@ static void send_request(int fd, struct strbuf *buf)
                safe_write(fd, buf->buf, buf->len);
 }
 
-#define INITIAL_FLUSH 32
+static void insert_one_alternate_ref(const struct ref *ref, void *unused)
+{
+       rev_list_insert_ref(NULL, ref->old_sha1, 0, NULL);
+}
+
+static void insert_alternate_refs(void)
+{
+       foreach_alt_odb(refs_from_alternate_cb, insert_one_alternate_ref);
+}
+
+#define INITIAL_FLUSH 16
 #define LARGE_FLUSH 1024
 
 static int next_flush(int count)
 {
-       if (count < LARGE_FLUSH)
+       if (count < INITIAL_FLUSH * 2)
+               count += INITIAL_FLUSH;
+       else if (count < LARGE_FLUSH)
                count <<= 1;
        else
                count += LARGE_FLUSH;
@@ -249,6 +262,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
        marked = 1;
 
        for_each_ref(rev_list_insert_ref, NULL);
+       insert_alternate_refs();
 
        fetching = 0;
        for ( ; refs ; refs = refs->next) {
@@ -831,6 +845,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
        char **pack_lockfile_ptr = NULL;
        struct child_process *conn;
 
+       packet_trace_identity("fetch-pack");
+
        nr_heads = 0;
        heads = NULL;
        for (i = 1; i < argc; i++) {