Update the gitweb/README file to include setting the GITWEB_CONFIG environment
[gitweb.git] / upload-pack.c
index 1f2f7f75e5c10f0beb708b282a911d52da77b60c..189b239cc093ab1d585627a647c7c36bf65efe18 100644 (file)
@@ -20,6 +20,9 @@ static int use_thin_pack;
 static struct object_array have_obj;
 static struct object_array want_obj;
 static unsigned int timeout;
+/* 0 for no sideband,
+ * otherwise maximum packet size (up to 65520 bytes).
+ */
 static int use_sideband;
 
 static void reset_timeout(void)
@@ -37,8 +40,7 @@ static int strip(char *line, int len)
 static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
 {
        if (use_sideband)
-               return send_sideband(1, fd, data, sz, DEFAULT_PACKET_MAX);
-
+               return send_sideband(1, fd, data, sz, use_sideband);
        if (fd == 3)
                /* emergency quit */
                fd = 2;
@@ -327,7 +329,8 @@ static int got_sha1(char *hex, unsigned char *sha1)
 static int get_common_commits(void)
 {
        static char line[1000];
-       unsigned char sha1[20], last_sha1[20];
+       unsigned char sha1[20];
+       char hex[41], last_hex[41];
        int len;
 
        track_object_refs = 0;
@@ -344,21 +347,22 @@ static int get_common_commits(void)
                }
                len = strip(line, len);
                if (!strncmp(line, "have ", 5)) {
-                       if (got_sha1(line+5, sha1) &&
-                           (multi_ack || have_obj.nr == 1)) {
-                               packet_write(1, "ACK %s%s\n",
-                                            sha1_to_hex(sha1),
-                                            multi_ack ?  " continue" : "");
-                               if (multi_ack)
-                                       hashcpy(last_sha1, sha1);
+                       if (got_sha1(line+5, sha1)) {
+                               memcpy(hex, sha1_to_hex(sha1), 41);
+                               if (multi_ack) {
+                                       const char *msg = "ACK %s continue\n";
+                                       packet_write(1, msg, hex);
+                                       memcpy(last_hex, hex, 41);
+                               }
+                               else if (have_obj.nr == 1)
+                                       packet_write(1, "ACK %s\n", hex);
                        }
                        continue;
                }
                if (!strcmp(line, "done")) {
                        if (have_obj.nr > 0) {
                                if (multi_ack)
-                                       packet_write(1, "ACK %s\n",
-                                                       sha1_to_hex(last_sha1));
+                                       packet_write(1, "ACK %s\n", last_hex);
                                return 0;
                        }
                        packet_write(1, "NAK\n");
@@ -389,8 +393,10 @@ static void receive_needs(void)
                        multi_ack = 1;
                if (strstr(line+45, "thin-pack"))
                        use_thin_pack = 1;
-               if (strstr(line+45, "side-band"))
-                       use_sideband = 1;
+               if (strstr(line+45, "side-band-64k"))
+                       use_sideband = LARGE_PACKET_MAX;
+               else if (strstr(line+45, "side-band"))
+                       use_sideband = DEFAULT_PACKET_MAX;
 
                /* We have sent all our refs already, and the other end
                 * should have chosen out of them; otherwise they are
@@ -412,7 +418,7 @@ static void receive_needs(void)
 
 static int send_ref(const char *refname, const unsigned char *sha1)
 {
-       static const char *capabilities = "multi_ack thin-pack side-band";
+       static const char *capabilities = "multi_ack thin-pack side-band side-band-64k";
        struct object *o = parse_object(sha1);
 
        if (!o)