Skip to content

Commit 90a6c7d

Browse files
Clemens Buchachergitster
authored andcommitted
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 <[email protected]> Cc: Todd Zullinger <[email protected]> Signed-off-by: Clemens Buchacher <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2579e1d commit 90a6c7d

File tree

6 files changed

+38
-9
lines changed

6 files changed

+38
-9
lines changed

Documentation/git-receive-pack.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-receive-pack - Receive what is pushed into the repository
88

99
SYNOPSIS
1010
--------
11-
'git-receive-pack' <directory>
11+
'git-receive-pack' [--quiet] <directory>
1212

1313
DESCRIPTION
1414
-----------
@@ -34,6 +34,9 @@ are not fast-forwards.
3434

3535
OPTIONS
3636
-------
37+
--quiet::
38+
Print only error messages.
39+
3740
<directory>::
3841
The repository to sync into.
3942

Documentation/git-send-pack.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-send-pack - Push objects over git protocol to another repository
88

99
SYNOPSIS
1010
--------
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>...]
1212

1313
DESCRIPTION
1414
-----------
@@ -44,6 +44,9 @@ OPTIONS
4444
the remote repository can lose commits; use it with
4545
care.
4646

47+
--quiet::
48+
Print only error messages.
49+
4750
--verbose::
4851
Run verbosely.
4952

builtin/receive-pack.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ static const char *parse_pack_header(struct pack_header *hdr)
636636

637637
static const char *pack_lockfile;
638638

639-
static const char *unpack(void)
639+
static const char *unpack(int quiet)
640640
{
641641
struct pack_header hdr;
642642
const char *hdr_err;
@@ -653,6 +653,8 @@ static const char *unpack(void)
653653
int code, i = 0;
654654
const char *unpacker[4];
655655
unpacker[i++] = "unpack-objects";
656+
if (quiet)
657+
unpacker[i++] = "-q";
656658
if (receive_fsck_objects)
657659
unpacker[i++] = "--strict";
658660
unpacker[i++] = hdr_arg;
@@ -753,6 +755,7 @@ static void add_alternate_refs(void)
753755

754756
int cmd_receive_pack(int argc, const char **argv, const char *prefix)
755757
{
758+
int quiet = 0;
756759
int advertise_refs = 0;
757760
int stateless_rpc = 0;
758761
int i;
@@ -766,6 +769,11 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
766769
const char *arg = *argv++;
767770

768771
if (*arg == '-') {
772+
if (!strcmp(arg, "--quiet")) {
773+
quiet = 1;
774+
continue;
775+
}
776+
769777
if (!strcmp(arg, "--advertise-refs")) {
770778
advertise_refs = 1;
771779
continue;
@@ -814,7 +822,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
814822
const char *unpack_status = NULL;
815823

816824
if (!delete_only(commands))
817-
unpack_status = unpack();
825+
unpack_status = unpack(quiet);
818826
execute_commands(commands, unpack_status);
819827
if (pack_lockfile)
820828
unlink_or_warn(pack_lockfile);

builtin/send-pack.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
439439
args.force_update = 1;
440440
continue;
441441
}
442+
if (!strcmp(arg, "--quiet")) {
443+
args.quiet = 1;
444+
continue;
445+
}
442446
if (!strcmp(arg, "--verbose")) {
443447
args.verbose = 1;
444448
continue;
@@ -488,8 +492,13 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
488492
fd[0] = 0;
489493
fd[1] = 1;
490494
} 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,
492500
args.verbose ? CONNECT_VERBOSE : 0);
501+
strbuf_release(&sb);
493502
}
494503

495504
memset(&extra_have, 0, sizeof(extra_have));

remote-curl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,9 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
766766
argv[argc++] = "--thin";
767767
if (options.dry_run)
768768
argv[argc++] = "--dry-run";
769-
if (options.verbosity > 1)
769+
if (options.verbosity < 0)
770+
argv[argc++] = "--quiet";
771+
else if (options.verbosity > 1)
770772
argv[argc++] = "--verbose";
771773
argv[argc++] = url;
772774
for (i = 0; i < nr_spec; i++)

transport.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,18 @@ static int set_git_option(struct git_transport_options *opts,
482482
static int connect_setup(struct transport *transport, int for_push, int verbose)
483483
{
484484
struct git_transport_data *data = transport->data;
485+
struct strbuf sb = STRBUF_INIT;
485486

486487
if (data->conn)
487488
return 0;
488489

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,
492495
verbose ? CONNECT_VERBOSE : 0);
496+
strbuf_release(&sb);
493497

494498
return 0;
495499
}

0 commit comments

Comments
 (0)