{"thread":{"id":"29316","subject":"[PATCH 1/3] server_supports(): parse feature list more carefully","startedAt":"2012-01-08T21:06:18Z","lastAt":"2012-01-08T21:06:21Z","messageCount":4,"participants":["Clemens Buchacher"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"182130","messageId":"1326056781-17456-1-git-send-email-drizzd@aon.at","threadId":"29316","inReplyTo":null,"subject":"enable push --quiet","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2012-01-08T21:06:18Z","receivedAt":"2012-01-08T21:06:18Z","isPatch":false,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Hi Junio,\n\nThis is a resend of the push --quiet bugfix \"series\".\n\n[PATCH 1/3] server_supports(): parse feature list more carefully\n[PATCH 2/3] fix push --quiet: add 'quiet' capability to receive-pack\n[PATCH 3/3] t5541: avoid TAP test miscounting\n\nI think it was looking good except for the TAP issue that you reported in this\nemail [1], which Michael \"fixes\" in PATCH 3/3, but which I could not reproduce\nand which was never really understood.\n\nThe series is also available as branch cb/push-quiet at\nhttp://github.com/drizzd/git .\n\nClemens\n\n[1] http://mid.gmane.org/7v62l7crpg.fsf@alter.siamese.dyndns.org\n"},{"id":"182129","messageId":"1326056781-17456-2-git-send-email-drizzd@aon.at","threadId":"29316","inReplyTo":"1326056781-17456-1-git-send-email-drizzd@aon.at","subject":"[PATCH 1/3] server_supports(): parse feature list more carefully","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2012-01-08T21:06:19Z","receivedAt":"2012-01-08T21:06:19Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nWe have been carefully choosing feature names used in the protocol\nextensions so that the vocabulary does not contain a word that is a\nsubstring of another word, so it is not a real problem, but we have\nrecently added \"quiet\" feature word, which would mean we cannot later\nadd some other word with \"quiet\" (e.g. \"quiet-push\"), which is awkward.\n\nLet's make sure that we can eventually be able to do so by teaching the\nclients and servers that feature words consist of non whitespace\nletters. This parser also allows us to later add features with parameters\ne.g. \"feature=1.5\" (parameter values need to be quoted for whitespaces,\nbut we will worry about the detauls when we do introduce them).\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n builtin/receive-pack.c |    5 +++--\n cache.h                |    1 +\n connect.c              |   23 +++++++++++++++++++++--\n upload-pack.c          |   22 +++++++++++++---------\n 4 files changed, 38 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex d2dcb7e..d8ddcaa 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -731,9 +731,10 @@ static struct command *read_head_info(void)\n \t\trefname = line + 82;\n \t\treflen = strlen(refname);\n \t\tif (reflen + 82 < len) {\n-\t\t\tif (strstr(refname + reflen + 1, \"report-status\"))\n+\t\t\tconst char *feature_list = refname + reflen + 1;\n+\t\t\tif (parse_feature_request(feature_list, \"report-status\"))\n \t\t\t\treport_status = 1;\n-\t\t\tif (strstr(refname + reflen + 1, \"side-band-64k\"))\n+\t\t\tif (parse_feature_request(feature_list, \"side-band-64k\"))\n \t\t\t\tuse_sideband = LARGE_PACKET_MAX;\n \t\t}\n \t\tcmd = xcalloc(1, sizeof(struct command) + len - 80);\ndiff --git a/cache.h b/cache.h\nindex 10afd71..9bd8c2d 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1037,6 +1037,7 @@ struct extra_have_objects {\n };\n extern struct ref **get_remote_heads(int in, struct ref **list, unsigned int flags, struct extra_have_objects *);\n extern int server_supports(const char *feature);\n+extern const char *parse_feature_request(const char *features, const char *feature);\n \n extern struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path);\n \ndiff --git a/connect.c b/connect.c\nindex 2ea5c3c..912cdde 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -101,8 +101,27 @@ struct ref **get_remote_heads(int in, struct ref **list,\n \n int server_supports(const char *feature)\n {\n-\treturn server_capabilities &&\n-\t\tstrstr(server_capabilities, feature) != NULL;\n+\treturn !!parse_feature_request(server_capabilities, feature);\n+}\n+\n+const char *parse_feature_request(const char *feature_list, const char *feature)\n+{\n+\tint len;\n+\n+\tif (!feature_list)\n+\t\treturn NULL;\n+\n+\tlen = strlen(feature);\n+\twhile (*feature_list) {\n+\t\tconst char *found = strstr(feature_list, feature);\n+\t\tif (!found)\n+\t\t\treturn NULL;\n+\t\tif ((feature_list == found || isspace(found[-1])) &&\n+\t\t    (!found[len] || isspace(found[len]) || found[len] == '='))\n+\t\t\treturn found;\n+\t\tfeature_list = found + 1;\n+\t}\n+\treturn NULL;\n }\n \n enum protocol {\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 6f36f62..0d11e21 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -585,6 +585,7 @@ static void receive_needs(void)\n \t\twrite_str_in_full(debug_fd, \"#S\\n\");\n \tfor (;;) {\n \t\tstruct object *o;\n+\t\tconst char *features;\n \t\tunsigned char sha1_buf[20];\n \t\tlen = packet_read_line(0, line, sizeof(line));\n \t\treset_timeout();\n@@ -616,23 +617,26 @@ static void receive_needs(void)\n \t\t    get_sha1_hex(line+5, sha1_buf))\n \t\t\tdie(\"git upload-pack: protocol error, \"\n \t\t\t    \"expected to get sha, not '%s'\", line);\n-\t\tif (strstr(line+45, \"multi_ack_detailed\"))\n+\n+\t\tfeatures = line + 45;\n+\n+\t\tif (parse_feature_request(features, \"multi_ack_detailed\"))\n \t\t\tmulti_ack = 2;\n-\t\telse if (strstr(line+45, \"multi_ack\"))\n+\t\telse if (parse_feature_request(features, \"multi_ack\"))\n \t\t\tmulti_ack = 1;\n-\t\tif (strstr(line+45, \"no-done\"))\n+\t\tif (parse_feature_request(features, \"no-done\"))\n \t\t\tno_done = 1;\n-\t\tif (strstr(line+45, \"thin-pack\"))\n+\t\tif (parse_feature_request(features, \"thin-pack\"))\n \t\t\tuse_thin_pack = 1;\n-\t\tif (strstr(line+45, \"ofs-delta\"))\n+\t\tif (parse_feature_request(features, \"ofs-delta\"))\n \t\t\tuse_ofs_delta = 1;\n-\t\tif (strstr(line+45, \"side-band-64k\"))\n+\t\tif (parse_feature_request(features, \"side-band-64k\"))\n \t\t\tuse_sideband = LARGE_PACKET_MAX;\n-\t\telse if (strstr(line+45, \"side-band\"))\n+\t\telse if (parse_feature_request(features, \"side-band\"))\n \t\t\tuse_sideband = DEFAULT_PACKET_MAX;\n-\t\tif (strstr(line+45, \"no-progress\"))\n+\t\tif (parse_feature_request(features, \"no-progress\"))\n \t\t\tno_progress = 1;\n-\t\tif (strstr(line+45, \"include-tag\"))\n+\t\tif (parse_feature_request(features, \"include-tag\"))\n \t\t\tuse_include_tag = 1;\n \n \t\to = lookup_object(sha1_buf);\n-- \n1.7.8\n"},{"id":"182132","messageId":"1326056781-17456-3-git-send-email-drizzd@aon.at","threadId":"29316","inReplyTo":"1326056781-17456-1-git-send-email-drizzd@aon.at","subject":"[PATCH 2/3] fix push --quiet: add 'quiet' capability to receive-pack","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2012-01-08T21:06:20Z","receivedAt":"2012-01-08T21:06:20Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Currently, git push --quiet produces some non-error output, e.g.:\n\n $ git push --quiet\n Unpacking objects: 100% (3/3), done.\n\nThis fixes a bug reported for the fedora git package:\n\n https://bugzilla.redhat.com/show_bug.cgi?id=725593\n\nReported-by: Jesse Keating <jkeating@redhat.com>\nCc: Todd Zullinger <tmz@pobox.com>\n\nCommit 90a6c7d4 (propagate --quiet to send-pack/receive-pack)\nintroduced the --quiet option to receive-pack and made send-pack\npass that option. Older versions of receive-pack do not recognize\nthe option, however, and terminate immediately. The commit was\ntherefore reverted.\n\nThis change instead adds a 'quiet' capability to receive-pack,\nwhich is a backwards compatible.\n\nIn addition, this fixes push --quiet via http: A verbosity of 0\nmeans quiet for remote helpers.\n\nReported-by: Tobias Ulmer <tobiasu@tmux.org>\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n builtin/receive-pack.c   |   14 ++++++++++++--\n builtin/send-pack.c      |   13 ++++++++++---\n remote-curl.c            |    4 +++-\n t/t5523-push-upstream.sh |    7 +++++++\n t/t5541-http-push.sh     |    8 ++++++++\n 5 files changed, 40 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex d8ddcaa..31d17cf 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -33,6 +33,7 @@ static int transfer_unpack_limit = -1;\n static int unpack_limit = 100;\n static int report_status;\n static int use_sideband;\n+static int quiet;\n static int prefer_ofs_delta = 1;\n static int auto_update_server_info;\n static int auto_gc = 1;\n@@ -122,7 +123,7 @@ static int show_ref(const char *path, const unsigned char *sha1, int flag, void\n \telse\n \t\tpacket_write(1, \"%s %s%c%s%s\\n\",\n \t\t\t     sha1_to_hex(sha1), path, 0,\n-\t\t\t     \" report-status delete-refs side-band-64k\",\n+\t\t\t     \" report-status delete-refs side-band-64k quiet\",\n \t\t\t     prefer_ofs_delta ? \" ofs-delta\" : \"\");\n \tsent_capabilities = 1;\n \treturn 0;\n@@ -736,6 +737,8 @@ static struct command *read_head_info(void)\n \t\t\t\treport_status = 1;\n \t\t\tif (parse_feature_request(feature_list, \"side-band-64k\"))\n \t\t\t\tuse_sideband = LARGE_PACKET_MAX;\n+\t\t\tif (parse_feature_request(feature_list, \"quiet\"))\n+\t\t\t\tquiet = 1;\n \t\t}\n \t\tcmd = xcalloc(1, sizeof(struct command) + len - 80);\n \t\thashcpy(cmd->old_sha1, old_sha1);\n@@ -789,8 +792,10 @@ static const char *unpack(void)\n \n \tif (ntohl(hdr.hdr_entries) < unpack_limit) {\n \t\tint code, i = 0;\n-\t\tconst char *unpacker[4];\n+\t\tconst char *unpacker[5];\n \t\tunpacker[i++] = \"unpack-objects\";\n+\t\tif (quiet)\n+\t\t\tunpacker[i++] = \"-q\";\n \t\tif (fsck_objects)\n \t\t\tunpacker[i++] = \"--strict\";\n \t\tunpacker[i++] = hdr_arg;\n@@ -904,6 +909,11 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)\n \t\tconst char *arg = *argv++;\n \n \t\tif (*arg == '-') {\n+\t\t\tif (!strcmp(arg, \"--quiet\")) {\n+\t\t\t\tquiet = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n \t\t\tif (!strcmp(arg, \"--advertise-refs\")) {\n \t\t\t\tadvertise_refs = 1;\n \t\t\t\tcontinue;\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex cd1115f..71f258e 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -263,6 +263,8 @@ int send_pack(struct send_pack_args *args,\n \t\targs->use_ofs_delta = 1;\n \tif (server_supports(\"side-band-64k\"))\n \t\tuse_sideband = 1;\n+\tif (!server_supports(\"quiet\"))\n+\t\targs->quiet = 0;\n \n \tif (!remote_refs) {\n \t\tfprintf(stderr, \"No refs in common and none specified; doing nothing.\\n\"\n@@ -301,11 +303,12 @@ int send_pack(struct send_pack_args *args,\n \t\t\tchar *old_hex = sha1_to_hex(ref->old_sha1);\n \t\t\tchar *new_hex = sha1_to_hex(ref->new_sha1);\n \n-\t\t\tif (!cmds_sent && (status_report || use_sideband)) {\n-\t\t\t\tpacket_buf_write(&req_buf, \"%s %s %s%c%s%s\",\n+\t\t\tif (!cmds_sent && (status_report || use_sideband || args->quiet)) {\n+\t\t\t\tpacket_buf_write(&req_buf, \"%s %s %s%c%s%s%s\",\n \t\t\t\t\told_hex, new_hex, ref->name, 0,\n \t\t\t\t\tstatus_report ? \" report-status\" : \"\",\n-\t\t\t\t\tuse_sideband ? \" side-band-64k\" : \"\");\n+\t\t\t\t\tuse_sideband ? \" side-band-64k\" : \"\",\n+\t\t\t\t\targs->quiet ? \" quiet\" : \"\");\n \t\t\t}\n \t\t\telse\n \t\t\t\tpacket_buf_write(&req_buf, \"%s %s %s\",\n@@ -439,6 +442,10 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)\n \t\t\t\targs.force_update = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--quiet\")) {\n+\t\t\t\targs.quiet = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--verbose\")) {\n \t\t\t\targs.verbose = 1;\n \t\t\t\tcontinue;\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 48c20b8..bcbc7fb 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -770,7 +770,9 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)\n \t\targv[argc++] = \"--thin\";\n \tif (options.dry_run)\n \t\targv[argc++] = \"--dry-run\";\n-\tif (options.verbosity > 1)\n+\tif (options.verbosity == 0)\n+\t\targv[argc++] = \"--quiet\";\n+\telse if (options.verbosity > 1)\n \t\targv[argc++] = \"--verbose\";\n \targv[argc++] = url;\n \tfor (i = 0; i < nr_spec; i++)\ndiff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh\nindex c229fe6..9ee52cf 100755\n--- a/t/t5523-push-upstream.sh\n+++ b/t/t5523-push-upstream.sh\n@@ -108,4 +108,11 @@ test_expect_failure TTY 'push --no-progress suppresses progress' '\n \t! grep \"Writing objects\" err\n '\n \n+test_expect_success TTY 'quiet push' '\n+\tensure_fresh_upstream &&\n+\n+\ttest_terminal git push --quiet --no-progress upstream master 2>&1 | tee output &&\n+\ttest_cmp /dev/null output\n+'\n+\n test_done\ndiff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh\nindex 9b85d42..0c3cd3b 100755\n--- a/t/t5541-http-push.sh\n+++ b/t/t5541-http-push.sh\n@@ -5,6 +5,7 @@\n \n test_description='test smart pushing over http via http-backend'\n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-terminal.sh\n \n if test -n \"$NO_CURL\"; then\n \tskip_all='skipping test, git built without http support'\n@@ -186,5 +187,12 @@ test_expect_success 'push --mirror to repo with alternates' '\n \tgit push --mirror \"$HTTPD_URL\"/smart/alternates-mirror.git\n '\n \n+test_expect_success TTY 'quiet push' '\n+\tcd \"$ROOT_PATH\"/test_repo_clone &&\n+\ttest_commit quiet &&\n+\ttest_terminal git push --quiet --no-progress 2>&1 | tee output &&\n+\ttest_cmp /dev/null output\n+'\n+\n stop_httpd\n test_done\n-- \n1.7.8\n"},{"id":"182131","messageId":"1326056781-17456-4-git-send-email-drizzd@aon.at","threadId":"29316","inReplyTo":"1326056781-17456-1-git-send-email-drizzd@aon.at","subject":"[PATCH 3/3] t5541: avoid TAP test miscounting","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2012-01-08T21:06:21Z","receivedAt":"2012-01-08T21:06:21Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"From: Michael J Gruber <git@drmicha.warpmail.net>\n\nlib-terminal.sh runs a test and thus increases the test count, but the\noutput is lost so that TAP produces a \"no plan found error\".\n\nMove the lib-terminal call after the lib-httpd and make TAP happy\n(though still leave me clueless).\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n t/t5541-http-push.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh\nindex 0c3cd3b..6c9ec6f 100755\n--- a/t/t5541-http-push.sh\n+++ b/t/t5541-http-push.sh\n@@ -5,7 +5,6 @@\n \n test_description='test smart pushing over http via http-backend'\n . ./test-lib.sh\n-. \"$TEST_DIRECTORY\"/lib-terminal.sh\n \n if test -n \"$NO_CURL\"; then\n \tskip_all='skipping test, git built without http support'\n@@ -15,6 +14,7 @@ fi\n ROOT_PATH=\"$PWD\"\n LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5541'}\n . \"$TEST_DIRECTORY\"/lib-httpd.sh\n+. \"$TEST_DIRECTORY\"/lib-terminal.sh\n start_httpd\n \n test_expect_success 'setup remote repository' '\n-- \n1.7.8\n"}]}