Skip to content

Commit 56b36b8

Browse files
committed
Merge branch 'jk/push-quiet'
* jk/push-quiet: transport: don't show push status if --quiet is given transport: pass "quiet" flag to pack-objects push: add --quiet flag
2 parents 14468ab + 481c7a6 commit 56b36b8

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

builtin-push.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
168168
const char *repo = NULL; /* default repository */
169169

170170
struct option options[] = {
171+
OPT_BIT('q', "quiet", &flags, "be quiet", TRANSPORT_PUSH_QUIET),
171172
OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE),
172173
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
173174
OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL),

builtin-send-pack.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
4444
NULL,
4545
NULL,
4646
NULL,
47+
NULL,
4748
};
4849
struct child_process po;
4950
int i;
@@ -53,6 +54,8 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
5354
argv[i++] = "--thin";
5455
if (args->use_ofs_delta)
5556
argv[i++] = "--delta-base-offset";
57+
if (args->quiet)
58+
argv[i++] = "-q";
5659
memset(&po, 0, sizeof(po));
5760
po.argv = argv;
5861
po.in = -1;

send-pack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
struct send_pack_args {
55
unsigned verbose:1,
6+
quiet:1,
67
send_mirror:1,
78
force_update:1,
89
use_thin_pack:1,

transport.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,21 @@ static int fetch_refs_via_pack(struct transport *transport,
667667
return (refs ? 0 : -1);
668668
}
669669

670+
static int push_had_errors(struct ref *ref)
671+
{
672+
for (; ref; ref = ref->next) {
673+
switch (ref->status) {
674+
case REF_STATUS_NONE:
675+
case REF_STATUS_UPTODATE:
676+
case REF_STATUS_OK:
677+
break;
678+
default:
679+
return 1;
680+
}
681+
}
682+
return 0;
683+
}
684+
670685
static int refs_pushed(struct ref *ref)
671686
{
672687
for (; ref; ref = ref->next) {
@@ -878,6 +893,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
878893
args.force_update = !!(flags & TRANSPORT_PUSH_FORCE);
879894
args.use_thin_pack = data->thin;
880895
args.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE);
896+
args.quiet = !!(flags & TRANSPORT_PUSH_QUIET);
881897
args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
882898

883899
ret = send_pack(&args, data->fd, data->conn, remote_refs,
@@ -995,6 +1011,7 @@ int transport_push(struct transport *transport,
9951011
struct ref *local_refs = get_local_heads();
9961012
int match_flags = MATCH_REFS_NONE;
9971013
int verbose = flags & TRANSPORT_PUSH_VERBOSE;
1014+
int quiet = flags & TRANSPORT_PUSH_QUIET;
9981015
int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
9991016
int ret;
10001017

@@ -1010,7 +1027,9 @@ int transport_push(struct transport *transport,
10101027

10111028
ret = transport->push_refs(transport, remote_refs, flags);
10121029

1013-
print_push_status(transport->url, remote_refs, verbose | porcelain, porcelain);
1030+
if (!quiet || push_had_errors(remote_refs))
1031+
print_push_status(transport->url, remote_refs,
1032+
verbose | porcelain, porcelain);
10141033

10151034
if (!(flags & TRANSPORT_PUSH_DRY_RUN)) {
10161035
struct ref *ref;

transport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct transport {
3636
#define TRANSPORT_PUSH_MIRROR 8
3737
#define TRANSPORT_PUSH_VERBOSE 16
3838
#define TRANSPORT_PUSH_PORCELAIN 32
39+
#define TRANSPORT_PUSH_QUIET 64
3940

4041
/* Returns a transport suitable for the url */
4142
struct transport *transport_get(struct remote *, const char *);

0 commit comments

Comments
 (0)