# [PATCH 0/3] ld/push-porcelain

6 messages from 2010-02-26 to 2010-02-27. Participants: Larry D'Anna, Tay Ray Chuan.
Thread: https://gitlist.dev/t/22835

## Larry D'Anna, 2010-02-26 20:44

Subject: [PATCH 0/3] ld/push-porcelain
Message-ID: <cover.1267216808.git.larry@elder-gods.org>
URL: https://gitlist.dev/e/cover.1267216808.git.larry%40elder-gods.org

```
Changes since last version:

* removed git-push: squelch advice message if in --porcelain mode
* chaned "error message" to "advice message" in commit subject

Larry D'Anna (3):
  git-push: fix an advice message so it goes to stderr
  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      |    6 +++---
 builtin-send-pack.c |    4 ++++
 send-pack.h         |    1 +
 transport.c         |    6 ++++--
 4 files changed, 12 insertions(+), 5 deletions(-)

```

## Larry D'Anna, 2010-02-26 20:44

Subject: [PATCH 1/3] git-push: fix an advice message so it goes to stderr
Message-ID: <68fd39ac6602471919939a84168be62f1fe464f7.1267216808.git.larry@elder-gods.org>
URL: https://gitlist.dev/e/68fd39ac6602471919939a84168be62f1fe464f7.1267216808.git.larry%40elder-gods.org
In-Reply-To: <cover.1267216808.git.larry@elder-gods.org>

```
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

```

## Larry D'Anna, 2010-02-26 20:44

Subject: [PATCH 2/3] git-push: send "To <remoteurl>" messages to the standard output in --porcelain mode
Message-ID: <0ecbc2ed26f4fe0a253bd34f94ffae8f71f81aea.1267216808.git.larry@elder-gods.org>
URL: https://gitlist.dev/e/0ecbc2ed26f4fe0a253bd34f94ffae8f71f81aea.1267216808.git.larry%40elder-gods.org
In-Reply-To: <cover.1267216808.git.larry@elder-gods.org>

```
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

```

## Larry D'Anna, 2010-02-26 20:44

Subject: [PATCH 3/3] git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejected
Message-ID: <6d253d15b5174c3982bcc434b7c2b361712d20cb.1267216808.git.larry@elder-gods.org>
URL: https://gitlist.dev/e/6d253d15b5174c3982bcc434b7c2b361712d20cb.1267216808.git.larry%40elder-gods.org
In-Reply-To: <cover.1267216808.git.larry@elder-gods.org>

```
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

```

## Tay Ray Chuan, 2010-02-27 02:44

Subject: Re: [PATCH 3/3] git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejected
Message-ID: <be6fef0d1002261844u5082b5bv90d46852218f632e@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d1002261844u5082b5bv90d46852218f632e%40mail.gmail.com
In-Reply-To: <6d253d15b5174c3982bcc434b7c2b361712d20cb.1267216808.git.larry@elder-gods.org>

```
Hi,

On Sat, Feb 27, 2010 at 4:44 AM, Larry D'Anna <larry@elder-gods.org> wrote:
> 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>

I thought that in the previous iteration, the status won't be touched
anymore? You agreed too:

  <20100210055529.GA1566@cthulhu>

-- 
Cheers,
Ray Chuan

```

## Larry D'Anna, 2010-02-27 04:01

Subject: Re: [PATCH 3/3] git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejected
Message-ID: <20100227040130.GA11517@cthulhu>
URL: https://gitlist.dev/e/20100227040130.GA11517%40cthulhu
In-Reply-To: <be6fef0d1002261844u5082b5bv90d46852218f632e@mail.gmail.com>

```
* Tay Ray Chuan (rctay89@gmail.com) [100226 21:44]:
> Hi,
> 
> On Sat, Feb 27, 2010 at 4:44 AM, Larry D'Anna <larry@elder-gods.org> wrote:
> > 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>
> 
> I thought that in the previous iteration, the status won't be touched
> anymore? You agreed too:
> 
>   <20100210055529.GA1566@cthulhu>

fixed.

        --larry

```
