Code

Merge branch 'jk/parse-object-cached'
authorJunio C Hamano <gitster@pobox.com>
Sun, 29 Jan 2012 21:18:55 +0000 (13:18 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 29 Jan 2012 21:18:55 +0000 (13:18 -0800)
* jk/parse-object-cached:
  upload-pack: avoid parsing tag destinations
  upload-pack: avoid parsing objects during ref advertisement
  parse_object: try internal cache before reading object db

1  2 
upload-pack.c

diff --combined upload-pack.c
index 0d11e21a68b227101d6c7f6f4d7b305d08f77d95,c01e161a9d713b64951210416d44e96835d12a64..bb08e2eb0dc52f68807a83b671fa61a2c2224f41
@@@ -585,7 -585,6 +585,7 @@@ static void receive_needs(void
                write_str_in_full(debug_fd, "#S\n");
        for (;;) {
                struct object *o;
 +              const char *features;
                unsigned char sha1_buf[20];
                len = packet_read_line(0, line, sizeof(line));
                reset_timeout();
                    get_sha1_hex(line+5, sha1_buf))
                        die("git upload-pack: protocol error, "
                            "expected to get sha, not '%s'", line);
 -              if (strstr(line+45, "multi_ack_detailed"))
 +
 +              features = line + 45;
 +
 +              if (parse_feature_request(features, "multi_ack_detailed"))
                        multi_ack = 2;
 -              else if (strstr(line+45, "multi_ack"))
 +              else if (parse_feature_request(features, "multi_ack"))
                        multi_ack = 1;
 -              if (strstr(line+45, "no-done"))
 +              if (parse_feature_request(features, "no-done"))
                        no_done = 1;
 -              if (strstr(line+45, "thin-pack"))
 +              if (parse_feature_request(features, "thin-pack"))
                        use_thin_pack = 1;
 -              if (strstr(line+45, "ofs-delta"))
 +              if (parse_feature_request(features, "ofs-delta"))
                        use_ofs_delta = 1;
 -              if (strstr(line+45, "side-band-64k"))
 +              if (parse_feature_request(features, "side-band-64k"))
                        use_sideband = LARGE_PACKET_MAX;
 -              else if (strstr(line+45, "side-band"))
 +              else if (parse_feature_request(features, "side-band"))
                        use_sideband = DEFAULT_PACKET_MAX;
 -              if (strstr(line+45, "no-progress"))
 +              if (parse_feature_request(features, "no-progress"))
                        no_progress = 1;
 -              if (strstr(line+45, "include-tag"))
 +              if (parse_feature_request(features, "include-tag"))
                        use_include_tag = 1;
  
                o = lookup_object(sha1_buf);
@@@ -724,11 -720,14 +724,14 @@@ static int send_ref(const char *refname
        static const char *capabilities = "multi_ack thin-pack side-band"
                " side-band-64k ofs-delta shallow no-progress"
                " include-tag multi_ack_detailed";
-       struct object *o = parse_object(sha1);
+       struct object *o = lookup_unknown_object(sha1);
        const char *refname_nons = strip_namespace(refname);
  
-       if (!o)
-               die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
+       if (o->type == OBJ_NONE) {
+               o->type = sha1_object_info(sha1, NULL);
+               if (o->type < 0)
+                   die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
+       }
  
        if (capabilities)
                packet_write(1, "%s %s%c%s%s\n", sha1_to_hex(sha1), refname_nons,
                nr_our_refs++;
        }
        if (o->type == OBJ_TAG) {
-               o = deref_tag(o, refname, 0);
+               o = deref_tag_noverify(o);
                if (o)
                        packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname_nons);
        }