Thread (6 messages) flat view 6 messages, 2 authors, 2016-06-15
DORMANTno replies

Revision v1 of 4 in this series.

Revisions (4)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v1 current
  4. v1 [diff vs current]

[PATCH 3/4] git-push: make git push --porcelain print "Done"

From: Larry D'Anna <hidden>
Date: 2016-06-15 22:48:21
Subsystem: the rest · Maintainer: Linus Torvalds

The script calling git push --porcelain can see clearly from the output if an
update was rejected.  However, it will probably need to distinguish this
condition from the push failing for other reasons, such as the remote not being
reachable.

This patch modifies git push --porcelain to print "Done" after the rest of its
output unless any errors have occurred which were not reported in the ref status
lines.

Signed-off-by: Larry D'Anna <redacted>
---
 builtin-send-pack.c |    4 ++++
 send-pack.h         |    1 +
 transport.c         |   15 ++++++++++-----
 3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 2183a47..87795f5 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -510,6 +510,10 @@ int send_pack(struct send_pack_args *args,
 
 	if (ret < 0)
 		return ret;
+
+	if (args->porcelain)
+		return 0;
+
 	for (ref = remote_refs; ref; ref = ref->next) {
 		switch (ref->status) {
 		case REF_STATUS_NONE:
diff --git a/send-pack.h b/send-pack.h
index 28141ac..60b4ba6 100644
--- a/send-pack.h
+++ b/send-pack.h
@@ -4,6 +4,7 @@
 struct send_pack_args {
 	unsigned verbose:1,
 		quiet:1,
+		porcelain:1,
 		send_mirror:1,
 		force_update:1,
 		use_thin_pack:1,
diff --git a/transport.c b/transport.c
index 32885f7..5b880d7 100644
--- a/transport.c
+++ b/transport.c
@@ -791,6 +791,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
 	args.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE);
 	args.quiet = !!(flags & TRANSPORT_PUSH_QUIET);
 	args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
+	args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
 
 	ret = send_pack(&args, data->fd, data->conn, remote_refs,
 			&data->extra_have);
@@ -1055,8 +1056,6 @@ int transport_push(struct transport *transport,
 		ret = transport->push_refs(transport, remote_refs, flags);
 		err = push_had_errors(remote_refs);
 
-		ret |= err;
-
 		if (!quiet || err)
 			print_push_status(transport->url, remote_refs,
 					verbose | porcelain, porcelain,
@@ -1071,9 +1070,15 @@ int transport_push(struct transport *transport,
 				update_tracking_ref(transport->remote, ref, verbose);
 		}
 
-		if (!quiet && !ret && !refs_pushed(remote_refs))
-			fprintf(stderr, "Everything up-to-date\n");
-		return ret;
+
+		if (porcelain) {
+			if (ret==0)
+				fprintf (stdout, "Done\n");
+		} else
+			if (!quiet && !ret && !refs_pushed(remote_refs))
+				fprintf(stderr, "Everything up-to-date\n");
+
+		return ret | err;
 	}
 	return 1;
 }
-- 
1.7.0.rc2.40.g7d8aa
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help