Skip to content

Commit 481c7a6

Browse files
peffgitster
authored andcommitted
transport: don't show push status if --quiet is given
When --quiet is given, the user generally only wants to see errors. So let's suppress printing the ref status table unless there is an error, in which case we print out the whole table. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1207032 commit 481c7a6

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

transport.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,21 @@ static int fetch_refs_via_pack(struct transport *transport,
681681
return (refs ? 0 : -1);
682682
}
683683

684+
static int push_had_errors(struct ref *ref)
685+
{
686+
for (; ref; ref = ref->next) {
687+
switch (ref->status) {
688+
case REF_STATUS_NONE:
689+
case REF_STATUS_UPTODATE:
690+
case REF_STATUS_OK:
691+
break;
692+
default:
693+
return 1;
694+
}
695+
}
696+
return 0;
697+
}
698+
684699
static int refs_pushed(struct ref *ref)
685700
{
686701
for (; ref; ref = ref->next) {
@@ -1010,6 +1025,7 @@ int transport_push(struct transport *transport,
10101025
struct ref *local_refs = get_local_heads();
10111026
int match_flags = MATCH_REFS_NONE;
10121027
int verbose = flags & TRANSPORT_PUSH_VERBOSE;
1028+
int quiet = flags & TRANSPORT_PUSH_QUIET;
10131029
int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
10141030
int ret;
10151031

@@ -1025,7 +1041,9 @@ int transport_push(struct transport *transport,
10251041

10261042
ret = transport->push_refs(transport, remote_refs, flags);
10271043

1028-
print_push_status(transport->url, remote_refs, verbose | porcelain, porcelain);
1044+
if (!quiet || push_had_errors(remote_refs))
1045+
print_push_status(transport->url, remote_refs,
1046+
verbose | porcelain, porcelain);
10291047

10301048
if (!(flags & TRANSPORT_PUSH_DRY_RUN)) {
10311049
struct ref *ref;

0 commit comments

Comments
 (0)