git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/4] git-push: squelch advice message if in --porcelain mode
  2010-02-09  5:48 ` [PATCH v3 2/3] git-push: clean up some of the output from git push --porcelain Larry D'Anna
@ 2010-02-09  5:54   ` Larry D'Anna
  0 siblings, 0 replies; 7+ messages in thread
From: Larry D'Anna @ 2010-02-09  5:54 UTC (permalink / raw)
  To: git; +Cc: Larry D'Anna

By default, git-push may give the user a verbose advice message if a ref is
rejected for not being a fast-forward.  This patch squelches that message for
--porcelain mode.

Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
 builtin-push.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/builtin-push.c b/builtin-push.c
index 0a27072..aacba45 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -226,6 +226,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 	argc = parse_options(argc, argv, prefix, options, push_usage, 0);
 
+	if (flags & TRANSPORT_PUSH_PORCELAIN) {
+		/* Do not give advice messages to Porcelain scripts */
+		advice_push_nonfastforward = 0;
+	}
+
 	if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
 		die("--delete is incompatible with --all, --mirror and --tags");
 	if (deleterefs && argc < 2)
-- 
1.7.0.rc1.33.g07cf0f.dirty

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 0/4] ld/push-porcelain
@ 2010-02-26 19:50 Larry D'Anna
  2010-02-26 19:50 ` [PATCH 1/4] git-push: fix an error message so it goes to stderr Larry D'Anna
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Larry D'Anna @ 2010-02-26 19:50 UTC (permalink / raw)
  To: git; +Cc: Larry D'Anna


I'm reposing this series to restart discussion on it. It's currently listed as
stalled.  The only change versus what's in pu is that this one doesn't mess with
the semantics of --quiet.  

So, what does it need?


Larry D'Anna (4):
  git-push: fix an error message so it goes to stderr
  git-push: squelch advice message if in --porcelain mode
  git-push: send "To <remoteurl>" messages to the standard output in
    --porcelain mode
  git-push: make git push --dry-run --porcelain exit with status 0 even
    if updates will be rejected

 builtin-push.c      |   11 ++++++++---
 builtin-send-pack.c |    4 ++++
 send-pack.h         |    1 +
 transport.c         |    6 ++++--
 4 files changed, 17 insertions(+), 5 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] git-push: fix an error message so it goes to stderr
  2010-02-26 19:50 [PATCH 0/4] ld/push-porcelain Larry D'Anna
@ 2010-02-26 19:50 ` Larry D'Anna
  2010-02-26 19:50 ` [PATCH 2/4] git-push: squelch advice message if in --porcelain mode Larry D'Anna
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Larry D'Anna @ 2010-02-26 19:50 UTC (permalink / raw)
  To: git; +Cc: Larry D'Anna

These sort of messages typically go to the standard error.

Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
 builtin-push.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin-push.c b/builtin-push.c
index 5633f0a..0a27072 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -124,9 +124,9 @@ static int push_with_options(struct transport *transport, int flags)
 		return 0;
 
 	if (nonfastforward && advice_push_nonfastforward) {
-		printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
-		       "Merge the remote changes before pushing again.  See the 'Note about\n"
-		       "fast-forwards' section of 'git push --help' for details.\n");
+		fprintf(stderr, "To prevent you from losing history, non-fast-forward updates were rejected\n"
+				"Merge the remote changes before pushing again.  See the 'Note about\n"
+				"fast-forwards' section of 'git push --help' for details.\n");
 	}
 
 	return 1;
-- 
1.7.0.rc2.40.g7d8aa

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] git-push: squelch advice message if in --porcelain mode
  2010-02-26 19:50 [PATCH 0/4] ld/push-porcelain Larry D'Anna
  2010-02-26 19:50 ` [PATCH 1/4] git-push: fix an error message so it goes to stderr Larry D'Anna
@ 2010-02-26 19:50 ` Larry D'Anna
  2010-02-26 20:04   ` Junio C Hamano
  2010-02-26 19:50 ` [PATCH 3/4] git-push: send "To <remoteurl>" messages to the standard output " Larry D'Anna
  2010-02-26 19:50 ` [PATCH 4/4] git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejected Larry D'Anna
  3 siblings, 1 reply; 7+ messages in thread
From: Larry D'Anna @ 2010-02-26 19:50 UTC (permalink / raw)
  To: git; +Cc: Larry D'Anna

By default, git-push may give the user a verbose advice message if a ref is
rejected for not being a fast-forward.  This patch squelches that message for
--porcelain mode.

Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
 builtin-push.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/builtin-push.c b/builtin-push.c
index 0a27072..aacba45 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -226,6 +226,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 	argc = parse_options(argc, argv, prefix, options, push_usage, 0);
 
+	if (flags & TRANSPORT_PUSH_PORCELAIN) {
+		/* Do not give advice messages to Porcelain scripts */
+		advice_push_nonfastforward = 0;
+	}
+
 	if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
 		die("--delete is incompatible with --all, --mirror and --tags");
 	if (deleterefs && argc < 2)
-- 
1.7.0.rc2.40.g7d8aa

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] git-push: send "To <remoteurl>" messages to the standard output in --porcelain mode
  2010-02-26 19:50 [PATCH 0/4] ld/push-porcelain Larry D'Anna
  2010-02-26 19:50 ` [PATCH 1/4] git-push: fix an error message so it goes to stderr Larry D'Anna
  2010-02-26 19:50 ` [PATCH 2/4] git-push: squelch advice message if in --porcelain mode Larry D'Anna
@ 2010-02-26 19:50 ` Larry D'Anna
  2010-02-26 19:50 ` [PATCH 4/4] git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejected Larry D'Anna
  3 siblings, 0 replies; 7+ messages in thread
From: Larry D'Anna @ 2010-02-26 19:50 UTC (permalink / raw)
  To: git; +Cc: Larry D'Anna

git-push prints the line "To <remoteurl>" before above each of the ref status
lines.  In --porcelain mode, these "To <remoteurl>" lines go to the standard
error, but the ref status lines go to the standard output.  This makes it
difficult for the process reading standard output to know which ref status lines
correspond to which remote.  This patch sends the "To <remoteurl>" lines to the
the standard output instead.

Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
 transport.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/transport.c b/transport.c
index 08e4fa0..32885f7 100644
--- a/transport.c
+++ b/transport.c
@@ -675,7 +675,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
 static int print_one_push_status(struct ref *ref, const char *dest, int count, int porcelain)
 {
 	if (!count)
-		fprintf(stderr, "To %s\n", dest);
+		fprintf(porcelain ? stdout : stderr, "To %s\n", dest);
 
 	switch(ref->status) {
 	case REF_STATUS_NONE:
-- 
1.7.0.rc2.40.g7d8aa

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejected
  2010-02-26 19:50 [PATCH 0/4] ld/push-porcelain Larry D'Anna
                   ` (2 preceding siblings ...)
  2010-02-26 19:50 ` [PATCH 3/4] git-push: send "To <remoteurl>" messages to the standard output " Larry D'Anna
@ 2010-02-26 19:50 ` Larry D'Anna
  3 siblings, 0 replies; 7+ messages in thread
From: Larry D'Anna @ 2010-02-26 19:50 UTC (permalink / raw)
  To: git; +Cc: Larry D'Anna

The script calling git push --dry-run --porcelain can see clearly from the
output that the updates will be rejected.  However, it will probably need to
distinguish this condition from the push failing for other reasons, such as the
remote not being reachable.

Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
 builtin-send-pack.c |    4 ++++
 send-pack.h         |    1 +
 transport.c         |    4 +++-
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 2183a47..2bf3d43 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 && args->dry_run)
+		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..8291621 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,7 +1056,8 @@ int transport_push(struct transport *transport,
 		ret = transport->push_refs(transport, remote_refs, flags);
 		err = push_had_errors(remote_refs);
 
-		ret |= err;
+		if ( !(pretend && porcelain) )
+			ret |= err;
 
 		if (!quiet || err)
 			print_push_status(transport->url, remote_refs,
-- 
1.7.0.rc2.40.g7d8aa

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/4] git-push: squelch advice message if in --porcelain mode
  2010-02-26 19:50 ` [PATCH 2/4] git-push: squelch advice message if in --porcelain mode Larry D'Anna
@ 2010-02-26 20:04   ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2010-02-26 20:04 UTC (permalink / raw)
  To: Larry D'Anna; +Cc: git

I thought that the previous discussion thread establish that [PATCH 2/4]
is no longer wanted, as long as we send the advice message to the standard
error output (which is done by [PATCH 1/4]---by the way, do not call that
"an error message").

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-02-26 20:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-26 19:50 [PATCH 0/4] ld/push-porcelain Larry D'Anna
2010-02-26 19:50 ` [PATCH 1/4] git-push: fix an error message so it goes to stderr Larry D'Anna
2010-02-26 19:50 ` [PATCH 2/4] git-push: squelch advice message if in --porcelain mode Larry D'Anna
2010-02-26 20:04   ` Junio C Hamano
2010-02-26 19:50 ` [PATCH 3/4] git-push: send "To <remoteurl>" messages to the standard output " Larry D'Anna
2010-02-26 19:50 ` [PATCH 4/4] git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejected Larry D'Anna
  -- strict thread matches above, loose matches on Subject: below --
2010-02-09  5:53 [PATCH 1/4] git-push: fix an error message so it goes to stderr Larry D'Anna
2010-02-09  5:48 ` [PATCH v3 2/3] git-push: clean up some of the output from git push --porcelain Larry D'Anna
2010-02-09  5:54   ` [PATCH 2/4] git-push: squelch advice message if in --porcelain mode Larry D'Anna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).