{"thread":{"id":"27964","subject":"[PATCH] propagate --quiet to send-pack/receive-pack","startedAt":"2011-07-30T12:10:14Z","lastAt":"2011-07-30T20:15:24Z","messageCount":2,"participants":["Clemens Buchacher","Todd Zullinger"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"172383","messageId":"20110730121014.GA899@toss.lan","threadId":"27964","inReplyTo":null,"subject":"[PATCH] propagate --quiet to send-pack/receive-pack","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2011-07-30T12:10:14Z","receivedAt":"2011-07-30T12:10:14Z","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\nAdd the --quiet option to send-pack/receive-pack and pass it to\nunpack-objects in the receive-pack codepath and to receive-pack in\nthe push codepath.\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>\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n\nPassing \"receive-pack --quiet\" to git_connect as a command string\nis a little ugly. But git_connect does the same internally, and I\ndid not want to add receive-pack specific options to git_connect,\nwhich is currently agnostic to such things.\n\nNote that IIRC, the non-quiet output (\"Unpacking objects...\") goes\nto stderr on purpose, not because it is an error, but because it\ncontains progress status information that we want to display even\nif standard output is redirected to a file.\n\nClemens\n\n Documentation/git-receive-pack.txt |    5 ++++-\n Documentation/git-send-pack.txt    |    5 ++++-\n builtin/receive-pack.c             |   12 ++++++++++--\n builtin/send-pack.c                |   11 ++++++++++-\n remote-curl.c                      |    4 +++-\n transport.c                        |   10 +++++++---\n 6 files changed, 38 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt\nindex 459c085..d7b68af 100644\n--- a/Documentation/git-receive-pack.txt\n+++ b/Documentation/git-receive-pack.txt\n@@ -9,7 +9,7 @@ git-receive-pack - Receive what is pushed into the repository\n SYNOPSIS\n --------\n [verse]\n-'git-receive-pack' <directory>\n+'git-receive-pack' [--quiet] <directory>\n \n DESCRIPTION\n -----------\n@@ -35,6 +35,9 @@ are not fast-forwards.\n \n OPTIONS\n -------\n+--quiet::\n+\tPrint only error messages.\n+\n <directory>::\n \tThe repository to sync into.\n \ndiff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt\nindex bd3eaa6..bed9e1f 100644\n--- a/Documentation/git-send-pack.txt\n+++ b/Documentation/git-send-pack.txt\n@@ -9,7 +9,7 @@ git-send-pack - Push objects over git protocol to another repository\n SYNOPSIS\n --------\n [verse]\n-'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n+'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--quiet] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n \n DESCRIPTION\n -----------\n@@ -45,6 +45,9 @@ OPTIONS\n \tthe remote repository can lose commits; use it with\n \tcare.\n \n+--quiet::\n+\tPrint only error messages.\n+\n --verbose::\n \tRun verbosely.\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex e1a687a..fca26fb 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -636,7 +636,7 @@ static const char *parse_pack_header(struct pack_header *hdr)\n \n static const char *pack_lockfile;\n \n-static const char *unpack(void)\n+static const char *unpack(int quiet)\n {\n \tstruct pack_header hdr;\n \tconst char *hdr_err;\n@@ -653,6 +653,8 @@ static const char *unpack(void)\n \t\tint code, i = 0;\n \t\tconst char *unpacker[4];\n \t\tunpacker[i++] = \"unpack-objects\";\n+\t\tif (quiet)\n+\t\t\tunpacker[i++] = \"-q\";\n \t\tif (receive_fsck_objects)\n \t\t\tunpacker[i++] = \"--strict\";\n \t\tunpacker[i++] = hdr_arg;\n@@ -753,6 +755,7 @@ static void add_alternate_refs(void)\n \n int cmd_receive_pack(int argc, const char **argv, const char *prefix)\n {\n+\tint quiet = 0;\n \tint advertise_refs = 0;\n \tint stateless_rpc = 0;\n \tint i;\n@@ -766,6 +769,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;\n@@ -814,7 +822,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)\n \t\tconst char *unpack_status = NULL;\n \n \t\tif (!delete_only(commands))\n-\t\t\tunpack_status = unpack();\n+\t\t\tunpack_status = unpack(quiet);\n \t\texecute_commands(commands, unpack_status);\n \t\tif (pack_lockfile)\n \t\t\tunlink_or_warn(pack_lockfile);\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex c1f6ddd..40a1675 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -439,6 +439,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;\n@@ -488,8 +492,13 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)\n \t\tfd[0] = 0;\n \t\tfd[1] = 1;\n \t} else {\n-\t\tconn = git_connect(fd, dest, receivepack,\n+\t\tstruct strbuf sb = STRBUF_INIT;\n+\t\tstrbuf_addstr(&sb, receivepack);\n+\t\tif (args.quiet)\n+\t\t\tstrbuf_addstr(&sb, \" --quiet\");\n+\t\tconn = git_connect(fd, dest, sb.buf,\n \t\t\targs.verbose ? CONNECT_VERBOSE : 0);\n+\t\tstrbuf_release(&sb);\n \t}\n \n \tmemset(&extra_have, 0, sizeof(extra_have));\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 69831e9..6d3aff6 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -762,7 +762,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/transport.c b/transport.c\nindex c9c8056..98c5778 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -482,14 +482,18 @@ static int set_git_option(struct git_transport_options *opts,\n static int connect_setup(struct transport *transport, int for_push, int verbose)\n {\n \tstruct git_transport_data *data = transport->data;\n+\tstruct strbuf sb = STRBUF_INIT;\n \n \tif (data->conn)\n \t\treturn 0;\n \n-\tdata->conn = git_connect(data->fd, transport->url,\n-\t\t\t\t for_push ? data->options.receivepack :\n-\t\t\t\t data->options.uploadpack,\n+\tstrbuf_addstr(&sb, for_push ? data->options.receivepack :\n+\t\t\t\t data->options.uploadpack);\n+\tif (for_push && transport->verbose < 0)\n+\t\tstrbuf_addstr(&sb, \" --quiet\");\n+\tdata->conn = git_connect(data->fd, transport->url, sb.buf,\n \t\t\t\t verbose ? CONNECT_VERBOSE : 0);\n+\tstrbuf_release(&sb);\n \n \treturn 0;\n }\n-- \n1.7.3.1.105.g84915\n"},{"id":"172412","messageId":"20110730201524.GD20477@zaya.localdomain","threadId":"27964","inReplyTo":"20110730121014.GA899@toss.lan","subject":"Re: [PATCH] propagate --quiet to send-pack/receive-pack","fromName":"Todd Zullinger","fromEmail":"tmz@pobox.com","sentAt":"2011-07-30T20:15:24Z","receivedAt":"2011-07-30T20:15:24Z","isPatch":true,"sender":{"key":"tmz@pobox.com","avatar":"https://avatars.githubusercontent.com/u/806319?v=4"},"body":"Clemens Buchacher wrote:\n> Currently, git push --quiet produces some non-error output, e.g.:\n>\n>  $ git push --quiet\n>  Unpacking objects: 100% (3/3), done.\n>\n> Add the --quiet option to send-pack/receive-pack and pass it to\n> unpack-objects in the receive-pack codepath and to receive-pack in\n> the push codepath.\n>\n> This fixes a bug reported for the fedora git package:\n>\n>  https://bugzilla.redhat.com/show_bug.cgi?id=725593\n\nThank you very much for the patch Clemens.  I've done some light\ntesting and it seems to fix the issue that Jesse reported.  I'll leave\nit up to the more compentent folks here to comment further.\n\nThanks again,\n\n-- \nTodd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nNever argue with an idiot. First, they drag you down to their level,\nthen beat you with experience.\n    -- Ben Adams\n\n"}]}