pathspec: small readability changes
[gitweb.git] / fetch-pack.c
index ad7d00f09c694248c4e1db6637ff772ef8c15f14..601f0779a1903a2b860412e3404e4ea8e4bce573 100644 (file)
@@ -240,7 +240,7 @@ static enum ack_type get_ack(int fd, unsigned char *result_sha1)
                        return ACK;
                }
        }
-       die(_("git fetch_pack: expected ACK/NAK, got '%s'"), line);
+       die(_("git fetch-pack: expected ACK/NAK, got '%s'"), line);
 }
 
 static void send_request(struct fetch_pack_args *args,
@@ -260,16 +260,21 @@ static void insert_one_alternate_ref(const struct ref *ref, void *unused)
 
 #define INITIAL_FLUSH 16
 #define PIPESAFE_FLUSH 32
-#define LARGE_FLUSH 1024
+#define LARGE_FLUSH 16384
 
 static int next_flush(struct fetch_pack_args *args, int count)
 {
-       int flush_limit = args->stateless_rpc ? LARGE_FLUSH : PIPESAFE_FLUSH;
-
-       if (count < flush_limit)
-               count <<= 1;
-       else
-               count += flush_limit;
+       if (args->stateless_rpc) {
+               if (count < LARGE_FLUSH)
+                       count <<= 1;
+               else
+                       count = count * 11 / 10;
+       } else {
+               if (count < PIPESAFE_FLUSH)
+                       count <<= 1;
+               else
+                       count += PIPESAFE_FLUSH;
+       }
        return count;
 }
 
@@ -324,6 +329,7 @@ static int find_common(struct fetch_pack_args *args,
                        if (no_done)            strbuf_addstr(&c, " no-done");
                        if (use_sideband == 2)  strbuf_addstr(&c, " side-band-64k");
                        if (use_sideband == 1)  strbuf_addstr(&c, " side-band");
+                       if (args->deepen_relative) strbuf_addstr(&c, " deepen-relative");
                        if (args->use_thin_pack) strbuf_addstr(&c, " thin-pack");
                        if (args->no_progress)   strbuf_addstr(&c, " no-progress");
                        if (args->include_tag)   strbuf_addstr(&c, " include-tag");
@@ -452,10 +458,17 @@ static int find_common(struct fetch_pack_args *args,
                                                const char *hex = sha1_to_hex(result_sha1);
                                                packet_buf_write(&req_buf, "have %s\n", hex);
                                                state_len = req_buf.len;
-                                       }
+                                               /*
+                                                * Reset in_vain because an ack
+                                                * for this commit has not been
+                                                * seen.
+                                                */
+                                               in_vain = 0;
+                                       } else if (!args->stateless_rpc
+                                                  || ack != ACK_common)
+                                               in_vain = 0;
                                        mark_common(commit, 0, 1);
                                        retval = 0;
-                                       in_vain = 0;
                                        got_continue = 1;
                                        if (ack == ACK_ready) {
                                                clear_prio_queue(&rev_list);
@@ -690,8 +703,9 @@ static int everything_local(struct fetch_pack_args *args,
 static int sideband_demux(int in, int out, void *data)
 {
        int *xd = data;
+       int ret;
 
-       int ret = recv_sideband("fetch-pack", xd[0], out);
+       ret = recv_sideband("fetch-pack", xd[0], out);
        close(out);
        return ret;
 }
@@ -716,6 +730,7 @@ static int get_pack(struct fetch_pack_args *args,
                demux.proc = sideband_demux;
                demux.data = xd;
                demux.out = -1;
+               demux.isolate_sigpipe = 1;
                if (start_async(&demux))
                        die(_("fetch-pack: unable to fork off sideband demultiplexer"));
        }
@@ -823,7 +838,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
        int agent_len;
 
        sort_ref_list(&ref, ref_compare_name);
-       qsort(sought, nr_sought, sizeof(*sought), cmp_ref_by_name);
+       QSORT(sought, nr_sought, cmp_ref_by_name);
 
        if ((args->depth > 0 || is_repository_shallow()) && !server_supports("shallow"))
                die(_("Server does not support shallow clients"));
@@ -883,6 +898,8 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
                deepen_not_ok = 1;
        else if (args->deepen_not)
                die(_("Server does not support --shallow-exclude"));
+       if (!server_supports("deepen-relative") && args->deepen_relative)
+               die(_("Server does not support --deepen"));
 
        if (everything_local(args, &ref, sought, nr_sought)) {
                packet_flush(fd[1]);