Code

Merge branch 'cb/push-quiet' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 6 Feb 2012 07:58:42 +0000 (23:58 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Feb 2012 07:58:42 +0000 (23:58 -0800)
* cb/push-quiet:
  t5541: avoid TAP test miscounting
  fix push --quiet: add 'quiet' capability to receive-pack
  server_supports(): parse feature list more carefully

1  2 
builtin/receive-pack.c

diff --combined builtin/receive-pack.c
index 8c9e91e78c95a4a3d581aae59d0f00bc95b2c942,31d17cf198d778f4ce5c5c49e74790f8c25f3681..fa7448be5aaf9d2830168b77f9a555e9b6740993
@@@ -33,6 -33,7 +33,7 @@@ static int transfer_unpack_limit = -1
  static int unpack_limit = 100;
  static int report_status;
  static int use_sideband;
+ static int quiet;
  static int prefer_ofs_delta = 1;
  static int auto_update_server_info;
  static int auto_gc = 1;
@@@ -115,19 -116,20 +116,19 @@@ static int receive_pack_config(const ch
        return git_default_config(var, value, cb);
  }
  
 -static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
 +static void show_ref(const char *path, const unsigned char *sha1)
  {
        if (sent_capabilities)
                packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
        else
                packet_write(1, "%s %s%c%s%s\n",
                             sha1_to_hex(sha1), path, 0,
-                            " report-status delete-refs side-band-64k",
+                            " report-status delete-refs side-band-64k quiet",
                             prefer_ofs_delta ? " ofs-delta" : "");
        sent_capabilities = 1;
 -      return 0;
  }
  
 -static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, void *cb_data)
 +static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, void *unused)
  {
        path = strip_namespace(path);
        /*
         */
        if (!path)
                path = ".have";
 -      return show_ref(path, sha1, flag, cb_data);
 +      show_ref(path, sha1);
 +      return 0;
 +}
 +
 +static void show_one_alternate_sha1(const unsigned char sha1[20], void *unused)
 +{
 +      show_ref(".have", sha1);
 +}
 +
 +static void collect_one_alternate_ref(const struct ref *ref, void *data)
 +{
 +      struct sha1_array *sa = data;
 +      sha1_array_append(sa, ref->old_sha1);
  }
  
  static void write_head_info(void)
  {
 +      struct sha1_array sa = SHA1_ARRAY_INIT;
 +      for_each_alternate_ref(collect_one_alternate_ref, &sa);
 +      sha1_array_for_each_unique(&sa, show_one_alternate_sha1, NULL);
 +      sha1_array_clear(&sa);
        for_each_ref(show_ref_cb, NULL);
        if (!sent_capabilities)
 -              show_ref("capabilities^{}", null_sha1, 0, NULL);
 +              show_ref("capabilities^{}", null_sha1);
  
 +      /* EOF */
 +      packet_flush(1);
  }
  
  struct command {
@@@ -748,10 -732,13 +749,13 @@@ static struct command *read_head_info(v
                refname = line + 82;
                reflen = strlen(refname);
                if (reflen + 82 < len) {
-                       if (strstr(refname + reflen + 1, "report-status"))
+                       const char *feature_list = refname + reflen + 1;
+                       if (parse_feature_request(feature_list, "report-status"))
                                report_status = 1;
-                       if (strstr(refname + reflen + 1, "side-band-64k"))
+                       if (parse_feature_request(feature_list, "side-band-64k"))
                                use_sideband = LARGE_PACKET_MAX;
+                       if (parse_feature_request(feature_list, "quiet"))
+                               quiet = 1;
                }
                cmd = xcalloc(1, sizeof(struct command) + len - 80);
                hashcpy(cmd->old_sha1, old_sha1);
@@@ -805,8 -792,10 +809,10 @@@ static const char *unpack(void
  
        if (ntohl(hdr.hdr_entries) < unpack_limit) {
                int code, i = 0;
-               const char *unpacker[4];
+               const char *unpacker[5];
                unpacker[i++] = "unpack-objects";
+               if (quiet)
+                       unpacker[i++] = "-q";
                if (fsck_objects)
                        unpacker[i++] = "--strict";
                unpacker[i++] = hdr_arg;
@@@ -886,6 -875,25 +892,6 @@@ static int delete_only(struct command *
        return 1;
  }
  
 -static void add_one_alternate_sha1(const unsigned char sha1[20], void *unused)
 -{
 -      add_extra_ref(".have", sha1, 0);
 -}
 -
 -static void collect_one_alternate_ref(const struct ref *ref, void *data)
 -{
 -      struct sha1_array *sa = data;
 -      sha1_array_append(sa, ref->old_sha1);
 -}
 -
 -static void add_alternate_refs(void)
 -{
 -      struct sha1_array sa = SHA1_ARRAY_INIT;
 -      for_each_alternate_ref(collect_one_alternate_ref, &sa);
 -      sha1_array_for_each_unique(&sa, add_one_alternate_sha1, NULL);
 -      sha1_array_clear(&sa);
 -}
 -
  int cmd_receive_pack(int argc, const char **argv, const char *prefix)
  {
        int advertise_refs = 0;
                const char *arg = *argv++;
  
                if (*arg == '-') {
+                       if (!strcmp(arg, "--quiet")) {
+                               quiet = 1;
+                               continue;
+                       }
                        if (!strcmp(arg, "--advertise-refs")) {
                                advertise_refs = 1;
                                continue;
                unpack_limit = receive_unpack_limit;
  
        if (advertise_refs || !stateless_rpc) {
 -              add_alternate_refs();
                write_head_info();
 -              clear_extra_refs();
 -
 -              /* EOF */
 -              packet_flush(1);
        }
        if (advertise_refs)
                return 0;