From afdeeb00eec471d86c9d421781ba8cb545be849c Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 5 Aug 2009 16:22:19 -0400 Subject: [PATCH 1/3] push: add --quiet flag Some transports produce output even without "--verbose" turned on. This provides a way to tell them to be more quiet (whereas simply redirecting might lose error messages). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-push.c | 1 + transport.h | 1 + 2 files changed, 2 insertions(+) diff --git a/builtin-push.c b/builtin-push.c index 1d92e22f0a..bc0c91aa4e 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -168,6 +168,7 @@ int cmd_push(int argc, const char **argv, const char *prefix) const char *repo = NULL; /* default repository */ struct option options[] = { + OPT_BIT('q', "quiet", &flags, "be quiet", TRANSPORT_PUSH_QUIET), OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE), OPT_STRING( 0 , "repo", &repo, "repository", "repository"), OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL), diff --git a/transport.h b/transport.h index 51b539778c..f1d3ebf674 100644 --- a/transport.h +++ b/transport.h @@ -36,6 +36,7 @@ struct transport { #define TRANSPORT_PUSH_MIRROR 8 #define TRANSPORT_PUSH_VERBOSE 16 #define TRANSPORT_PUSH_PORCELAIN 32 +#define TRANSPORT_PUSH_QUIET 64 /* Returns a transport suitable for the url */ struct transport *transport_get(struct remote *, const char *); From 120703292b2828d3c35c937b7f5e75ec570a42e9 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 5 Aug 2009 16:22:36 -0400 Subject: [PATCH 2/3] transport: pass "quiet" flag to pack-objects When pushing over the git protocol, pack-objects gives progress reports about the pack being sent. If "push" is given the --quiet flag, it now passes "-q" to pack-objects, suppressing this output. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-send-pack.c | 3 +++ send-pack.h | 1 + transport.c | 1 + 3 files changed, 5 insertions(+) diff --git a/builtin-send-pack.c b/builtin-send-pack.c index 47fb9f7baa..37e528e283 100644 --- a/builtin-send-pack.c +++ b/builtin-send-pack.c @@ -44,6 +44,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext NULL, NULL, NULL, + NULL, }; struct child_process po; int i; @@ -53,6 +54,8 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext argv[i++] = "--thin"; if (args->use_ofs_delta) argv[i++] = "--delta-base-offset"; + if (args->quiet) + argv[i++] = "-q"; memset(&po, 0, sizeof(po)); po.argv = argv; po.in = -1; diff --git a/send-pack.h b/send-pack.h index 1d7b1b3b4f..8b3cf028ed 100644 --- a/send-pack.h +++ b/send-pack.h @@ -3,6 +3,7 @@ struct send_pack_args { unsigned verbose:1, + quiet:1, send_mirror:1, force_update:1, use_thin_pack:1, diff --git a/transport.c b/transport.c index de0d5874a3..c3191ed201 100644 --- a/transport.c +++ b/transport.c @@ -892,6 +892,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re args.force_update = !!(flags & TRANSPORT_PUSH_FORCE); args.use_thin_pack = data->thin; args.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE); + args.quiet = !!(flags & TRANSPORT_PUSH_QUIET); args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN); ret = send_pack(&args, data->fd, data->conn, remote_refs, From 481c7a6db907774d0f06565d00fd06500a7ae7a4 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 5 Aug 2009 16:23:26 -0400 Subject: [PATCH 3/3] 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 Signed-off-by: Junio C Hamano --- transport.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/transport.c b/transport.c index c3191ed201..a3d0145116 100644 --- a/transport.c +++ b/transport.c @@ -681,6 +681,21 @@ static int fetch_refs_via_pack(struct transport *transport, return (refs ? 0 : -1); } +static int push_had_errors(struct ref *ref) +{ + for (; ref; ref = ref->next) { + switch (ref->status) { + case REF_STATUS_NONE: + case REF_STATUS_UPTODATE: + case REF_STATUS_OK: + break; + default: + return 1; + } + } + return 0; +} + static int refs_pushed(struct ref *ref) { for (; ref; ref = ref->next) { @@ -1010,6 +1025,7 @@ int transport_push(struct transport *transport, struct ref *local_refs = get_local_heads(); int match_flags = MATCH_REFS_NONE; int verbose = flags & TRANSPORT_PUSH_VERBOSE; + int quiet = flags & TRANSPORT_PUSH_QUIET; int porcelain = flags & TRANSPORT_PUSH_PORCELAIN; int ret; @@ -1025,7 +1041,9 @@ int transport_push(struct transport *transport, ret = transport->push_refs(transport, remote_refs, flags); - print_push_status(transport->url, remote_refs, verbose | porcelain, porcelain); + if (!quiet || push_had_errors(remote_refs)) + print_push_status(transport->url, remote_refs, + verbose | porcelain, porcelain); if (!(flags & TRANSPORT_PUSH_DRY_RUN)) { struct ref *ref;