gitweb: Drop the href() params which keys are not in %mapping
[gitweb.git] / upload-pack.c
index 5a911d6fb52757b4f988193eb37eeee54e5002ce..fcf279843ad23b0605f3c2bc558e8d04a903554b 100644 (file)
@@ -14,12 +14,12 @@ static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=n
 #define THEY_HAVE (1U << 0)
 #define OUR_REF (1U << 1)
 #define WANTED (1U << 2)
-static int multi_ack = 0, nr_our_refs = 0;
-static int use_thin_pack = 0;
+static int multi_ack, nr_our_refs;
+static int use_thin_pack;
 static struct object_array have_obj;
 static struct object_array want_obj;
-static unsigned int timeout = 0;
-static int use_sideband = 0;
+static unsigned int timeout;
+static int use_sideband;
 
 static void reset_timeout(void)
 {
@@ -49,6 +49,10 @@ static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
                if (fd == 3)
                        /* emergency quit */
                        fd = 2;
+               if (fd == 2) {
+                       xwrite(fd, data, sz);
+                       return sz;
+               }
                return safe_write(fd, data, sz);
        }
        p = data;
@@ -178,6 +182,8 @@ static void create_pack_file(void)
                ssize_t sz;
                int pe, pu, pollsize;
 
+               reset_timeout();
+
                pollsize = 0;
                pe = pu = -1;
 
@@ -328,7 +334,7 @@ static int got_sha1(char *hex, unsigned char *sha1)
                o = parse_object(sha1);
        if (!o)
                die("oops (%s)", sha1_to_hex(sha1));
-       if (o->type == TYPE_COMMIT) {
+       if (o->type == OBJ_COMMIT) {
                struct commit_list *parents;
                if (o->flags & THEY_HAVE)
                        return 0;
@@ -446,25 +452,24 @@ static int send_ref(const char *refname, const unsigned char *sha1)
                o->flags |= OUR_REF;
                nr_our_refs++;
        }
-       if (o->type == TYPE_TAG) {
+       if (o->type == OBJ_TAG) {
                o = deref_tag(o, refname, 0);
                packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
        }
        return 0;
 }
 
-static int upload_pack(void)
+static void upload_pack(void)
 {
        reset_timeout();
        head_ref(send_ref);
        for_each_ref(send_ref);
        packet_flush(1);
        receive_needs();
-       if (!want_obj.nr)
-               return 0;
-       get_common_commits();
-       create_pack_file();
-       return 0;
+       if (want_obj.nr) {
+               get_common_commits();
+               create_pack_file();
+       }
 }
 
 int main(int argc, char **argv)