@matheusbsbs / matheus-bagliano / commits / 481c7a6db9
Fork 0

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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 5, 2009 at 16:23 UTC 481c7a6db907774d0f06565d00fd06500a7ae7a4
1 file changed +19 -1
transport.c
+19 -1
@@ -681,6 +681,21 @@ static int fetch_refs_via_pack(struct transport *transport,
681 return (refs ? 0 : -1);
682 }
683
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 +
699 static int refs_pushed(struct ref *ref)
700 {
701 for (; ref; ref = ref->next) {
@@ -1010,6 +1025,7 @@ int transport_push(struct transport *transport,
1025 struct ref *local_refs = get_local_heads();
1026 int match_flags = MATCH_REFS_NONE;
1027 int verbose = flags & TRANSPORT_PUSH_VERBOSE;
1028 + int quiet = flags & TRANSPORT_PUSH_QUIET;
1029 int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
1030 int ret;
1031
@@ -1025,7 +1041,9 @@ int transport_push(struct transport *transport,
1041
1042 ret = transport->push_refs(transport, remote_refs, flags);
1043
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);
1047
1048 if (!(flags & TRANSPORT_PUSH_DRY_RUN)) {
1049 struct ref *ref;