Skip to content

Commit c207e34

Browse files
Clemens Buchachergitster
authored andcommitted
fix push --quiet: add 'quiet' capability to receive-pack
Currently, git push --quiet produces some non-error output, e.g.: $ git push --quiet Unpacking objects: 100% (3/3), done. 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]> Commit 90a6c7d (propagate --quiet to send-pack/receive-pack) introduced the --quiet option to receive-pack and made send-pack pass that option. Older versions of receive-pack do not recognize the option, however, and terminate immediately. The commit was therefore reverted. This change instead adds a 'quiet' capability to receive-pack, which is a backwards compatible. In addition, this fixes push --quiet via http: A verbosity of 0 means quiet for remote helpers. Reported-by: Tobias Ulmer <[email protected]> Signed-off-by: Clemens Buchacher <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f47182c commit c207e34

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

builtin/receive-pack.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static int transfer_unpack_limit = -1;
3333
static int unpack_limit = 100;
3434
static int report_status;
3535
static int use_sideband;
36+
static int quiet;
3637
static int prefer_ofs_delta = 1;
3738
static int auto_update_server_info;
3839
static int auto_gc = 1;
@@ -122,7 +123,7 @@ static int show_ref(const char *path, const unsigned char *sha1, int flag, void
122123
else
123124
packet_write(1, "%s %s%c%s%s\n",
124125
sha1_to_hex(sha1), path, 0,
125-
" report-status delete-refs side-band-64k",
126+
" report-status delete-refs side-band-64k quiet",
126127
prefer_ofs_delta ? " ofs-delta" : "");
127128
sent_capabilities = 1;
128129
return 0;
@@ -736,6 +737,8 @@ static struct command *read_head_info(void)
736737
report_status = 1;
737738
if (parse_feature_request(feature_list, "side-band-64k"))
738739
use_sideband = LARGE_PACKET_MAX;
740+
if (parse_feature_request(feature_list, "quiet"))
741+
quiet = 1;
739742
}
740743
cmd = xcalloc(1, sizeof(struct command) + len - 80);
741744
hashcpy(cmd->old_sha1, old_sha1);
@@ -789,8 +792,10 @@ static const char *unpack(void)
789792

790793
if (ntohl(hdr.hdr_entries) < unpack_limit) {
791794
int code, i = 0;
792-
const char *unpacker[4];
795+
const char *unpacker[5];
793796
unpacker[i++] = "unpack-objects";
797+
if (quiet)
798+
unpacker[i++] = "-q";
794799
if (fsck_objects)
795800
unpacker[i++] = "--strict";
796801
unpacker[i++] = hdr_arg;
@@ -904,6 +909,11 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
904909
const char *arg = *argv++;
905910

906911
if (*arg == '-') {
912+
if (!strcmp(arg, "--quiet")) {
913+
quiet = 1;
914+
continue;
915+
}
916+
907917
if (!strcmp(arg, "--advertise-refs")) {
908918
advertise_refs = 1;
909919
continue;

builtin/send-pack.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ int send_pack(struct send_pack_args *args,
263263
args->use_ofs_delta = 1;
264264
if (server_supports("side-band-64k"))
265265
use_sideband = 1;
266+
if (!server_supports("quiet"))
267+
args->quiet = 0;
266268

267269
if (!remote_refs) {
268270
fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
@@ -301,11 +303,12 @@ int send_pack(struct send_pack_args *args,
301303
char *old_hex = sha1_to_hex(ref->old_sha1);
302304
char *new_hex = sha1_to_hex(ref->new_sha1);
303305

304-
if (!cmds_sent && (status_report || use_sideband)) {
305-
packet_buf_write(&req_buf, "%s %s %s%c%s%s",
306+
if (!cmds_sent && (status_report || use_sideband || args->quiet)) {
307+
packet_buf_write(&req_buf, "%s %s %s%c%s%s%s",
306308
old_hex, new_hex, ref->name, 0,
307309
status_report ? " report-status" : "",
308-
use_sideband ? " side-band-64k" : "");
310+
use_sideband ? " side-band-64k" : "",
311+
args->quiet ? " quiet" : "");
309312
}
310313
else
311314
packet_buf_write(&req_buf, "%s %s %s",
@@ -439,6 +442,10 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
439442
args.force_update = 1;
440443
continue;
441444
}
445+
if (!strcmp(arg, "--quiet")) {
446+
args.quiet = 1;
447+
continue;
448+
}
442449
if (!strcmp(arg, "--verbose")) {
443450
args.verbose = 1;
444451
continue;

remote-curl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,9 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
770770
argv[argc++] = "--thin";
771771
if (options.dry_run)
772772
argv[argc++] = "--dry-run";
773-
if (options.verbosity > 1)
773+
if (options.verbosity == 0)
774+
argv[argc++] = "--quiet";
775+
else if (options.verbosity > 1)
774776
argv[argc++] = "--verbose";
775777
argv[argc++] = url;
776778
for (i = 0; i < nr_spec; i++)

t/t5523-push-upstream.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,11 @@ test_expect_failure TTY 'push --no-progress suppresses progress' '
108108
! grep "Writing objects" err
109109
'
110110

111+
test_expect_success TTY 'quiet push' '
112+
ensure_fresh_upstream &&
113+
114+
test_terminal git push --quiet --no-progress upstream master 2>&1 | tee output &&
115+
test_cmp /dev/null output
116+
'
117+
111118
test_done

t/t5541-http-push.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
test_description='test smart pushing over http via http-backend'
77
. ./test-lib.sh
8+
. "$TEST_DIRECTORY"/lib-terminal.sh
89

910
if test -n "$NO_CURL"; then
1011
skip_all='skipping test, git built without http support'
@@ -186,5 +187,12 @@ test_expect_success 'push --mirror to repo with alternates' '
186187
git push --mirror "$HTTPD_URL"/smart/alternates-mirror.git
187188
'
188189

190+
test_expect_success TTY 'quiet push' '
191+
cd "$ROOT_PATH"/test_repo_clone &&
192+
test_commit quiet &&
193+
test_terminal git push --quiet --no-progress 2>&1 | tee output &&
194+
test_cmp /dev/null output
195+
'
196+
189197
stop_httpd
190198
test_done

0 commit comments

Comments
 (0)