Skip to content

Commit ffa69e6

Browse files
committed
Merge branch 'cb/maint-quiet-push' into maint
* cb/maint-quiet-push: receive-pack: do not overstep command line argument array propagate --quiet to send-pack/receive-pack Conflicts: Documentation/git-receive-pack.txt Documentation/git-send-pack.txt
2 parents 4a13c4d + 0d086b8 commit ffa69e6

File tree

6 files changed

+39
-10
lines changed

6 files changed

+39
-10
lines changed

Documentation/git-receive-pack.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-receive-pack - Receive what is pushed into the repository
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'git-receive-pack' <directory>
12+
'git-receive-pack' [--quiet] <directory>
1313

1414
DESCRIPTION
1515
-----------
@@ -35,6 +35,9 @@ are not fast-forwards.
3535

3636
OPTIONS
3737
-------
38+
--quiet::
39+
Print only error messages.
40+
3841
<directory>::
3942
The repository to sync into.
4043

Documentation/git-send-pack.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-send-pack - Push objects over git protocol to another repository
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]
12+
'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--quiet] [--verbose] [--thin] [<host>:]<directory> [<ref>...]
1313

1414
DESCRIPTION
1515
-----------
@@ -45,6 +45,9 @@ OPTIONS
4545
the remote repository can lose commits; use it with
4646
care.
4747

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

builtin/receive-pack.c

Lines changed: 11 additions & 3 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;
@@ -651,8 +651,10 @@ static const char *unpack(void)
651651

652652
if (ntohl(hdr.hdr_entries) < unpack_limit) {
653653
int code, i = 0;
654-
const char *unpacker[4];
654+
const char *unpacker[5];
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
@@ -762,7 +762,9 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
762762
argv[argc++] = "--thin";
763763
if (options.dry_run)
764764
argv[argc++] = "--dry-run";
765-
if (options.verbosity > 1)
765+
if (options.verbosity < 0)
766+
argv[argc++] = "--quiet";
767+
else if (options.verbosity > 1)
766768
argv[argc++] = "--verbose";
767769
argv[argc++] = url;
768770
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)