propagate --quiet to send-pack/receive-pack

Currently, git push --quiet produces some non-error output, e.g.: $ git push --quiet Unpacking objects: 100% (3/3), done. Add the --quiet option to send-pack/receive-pack and pass it to unpack-objects in the receive-pack codepath and to receive-pack in the push codepath. This fixes a bug reported for the fedora git package: https://bugzilla.redhat.com/show_bug.cgi?id=725593 Reported-by: Jesse Keating <jkeating@redhat.com> Cc: Todd Zullinger <tmz@pobox.com> Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Clemens Buchacher committed Jul 30, 2011 at 14:10 UTC 90a6c7d443058e8ad3eb36d21f4ede99addbca61
6 files changed +38 -9
Documentation/git-receive-pack.txt
+4 -1
@@ -8,7 +8,7 @@ git-receive-pack - Receive what is pushed into the repository
8
9 SYNOPSIS
10 --------
11 -'git-receive-pack' <directory>
11 +'git-receive-pack' [--quiet] <directory>
12
13 DESCRIPTION
14 -----------
@@ -34,6 +34,9 @@ are not fast-forwards.
34
35 OPTIONS
36 -------
37 +--quiet::
38 + Print only error messages.
39 +
40 <directory>::
41 The repository to sync into.
42
Documentation/git-send-pack.txt
+4 -1
@@ -8,7 +8,7 @@ git-send-pack - Push objects over git protocol to another repository
8
9 SYNOPSIS
10 --------
11 -'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]
11 +'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--quiet] [--verbose] [--thin] [<host>:]<directory> [<ref>...]
12
13 DESCRIPTION
14 -----------
@@ -44,6 +44,9 @@ OPTIONS
44 the remote repository can lose commits; use it with
45 care.
46
47 +--quiet::
48 + Print only error messages.
49 +
50 --verbose::
51 Run verbosely.
52
builtin/receive-pack.c
+10 -2
@@ -636,7 +636,7 @@ static const char *parse_pack_header(struct pack_header *hdr)
636
637 static const char *pack_lockfile;
638
639 -static const char *unpack(void)
639 +static const char *unpack(int quiet)
640 {
641 struct pack_header hdr;
642 const char *hdr_err;
@@ -653,6 +653,8 @@ static const char *unpack(void)
653 int code, i = 0;
654 const char *unpacker[4];
655 unpacker[i++] = "unpack-objects";
656 + if (quiet)
657 + unpacker[i++] = "-q";
658 if (receive_fsck_objects)
659 unpacker[i++] = "--strict";
660 unpacker[i++] = hdr_arg;
@@ -753,6 +755,7 @@ static void add_alternate_refs(void)
755
756 int cmd_receive_pack(int argc, const char **argv, const char *prefix)
757 {
758 + int quiet = 0;
759 int advertise_refs = 0;
760 int stateless_rpc = 0;
761 int i;
@@ -766,6 +769,11 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
769 const char *arg = *argv++;
770
771 if (*arg == '-') {
772 + if (!strcmp(arg, "--quiet")) {
773 + quiet = 1;
774 + continue;
775 + }
776 +
777 if (!strcmp(arg, "--advertise-refs")) {
778 advertise_refs = 1;
779 continue;
@@ -814,7 +822,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
822 const char *unpack_status = NULL;
823
824 if (!delete_only(commands))
817 - unpack_status = unpack();
825 + unpack_status = unpack(quiet);
826 execute_commands(commands, unpack_status);
827 if (pack_lockfile)
828 unlink_or_warn(pack_lockfile);
builtin/send-pack.c
+10 -1
@@ -439,6 +439,10 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
439 args.force_update = 1;
440 continue;
441 }
442 + if (!strcmp(arg, "--quiet")) {
443 + args.quiet = 1;
444 + continue;
445 + }
446 if (!strcmp(arg, "--verbose")) {
447 args.verbose = 1;
448 continue;
@@ -488,8 +492,13 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
492 fd[0] = 0;
493 fd[1] = 1;
494 } else {
491 - conn = git_connect(fd, dest, receivepack,
495 + struct strbuf sb = STRBUF_INIT;
496 + strbuf_addstr(&sb, receivepack);
497 + if (args.quiet)
498 + strbuf_addstr(&sb, " --quiet");
499 + conn = git_connect(fd, dest, sb.buf,
500 args.verbose ? CONNECT_VERBOSE : 0);
501 + strbuf_release(&sb);
502 }
503
504 memset(&extra_have, 0, sizeof(extra_have));
remote-curl.c
+3 -1
@@ -766,7 +766,9 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
766 argv[argc++] = "--thin";
767 if (options.dry_run)
768 argv[argc++] = "--dry-run";
769 - if (options.verbosity > 1)
769 + if (options.verbosity < 0)
770 + argv[argc++] = "--quiet";
771 + else if (options.verbosity > 1)
772 argv[argc++] = "--verbose";
773 argv[argc++] = url;
774 for (i = 0; i < nr_spec; i++)
transport.c
+7 -3
@@ -482,14 +482,18 @@ static int set_git_option(struct git_transport_options *opts,
482 static int connect_setup(struct transport *transport, int for_push, int verbose)
483 {
484 struct git_transport_data *data = transport->data;
485 + struct strbuf sb = STRBUF_INIT;
486
487 if (data->conn)
488 return 0;
489
489 - data->conn = git_connect(data->fd, transport->url,
490 - for_push ? data->options.receivepack :
491 - data->options.uploadpack,
490 + strbuf_addstr(&sb, for_push ? data->options.receivepack :
491 + data->options.uploadpack);
492 + if (for_push && transport->verbose < 0)
493 + strbuf_addstr(&sb, " --quiet");
494 + data->conn = git_connect(data->fd, transport->url, sb.buf,
495 verbose ? CONNECT_VERBOSE : 0);
496 + strbuf_release(&sb);
497
498 return 0;
499 }