{"thread":{"id":"22579","subject":"[PATCH 2/4] git-push: squelch advice message if in --porcelain mode","startedAt":"2010-02-09T05:53:59Z","lastAt":"2010-02-11T23:19:34Z","messageCount":6,"participants":["Larry D'Anna","Tay Ray Chuan","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"134001","messageId":"1d1ce7e0ad28fd0cad8d9d7bfeda04ba58be36d4.1265694627.git.larry@elder-gods.org","threadId":"22579","inReplyTo":"20100209054820.GA30907@cthulhu","subject":"[PATCH 1/4] git-push: fix an error message so it goes to stderr","fromName":"Larry D'Anna","fromEmail":"larry@elder-gods.org","sentAt":"2010-02-09T05:53:59Z","receivedAt":"2010-02-09T05:53:59Z","isPatch":true,"sender":{"key":"larry@elder-gods.org","avatar":"https://avatars.githubusercontent.com/u/3013304?v=4"},"body":"These sort of messages typically go to the standard error.\n\nSigned-off-by: Larry D'Anna <larry@elder-gods.org>\n---\n builtin-push.c |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-push.c b/builtin-push.c\nindex 5633f0a..0a27072 100644\n--- a/builtin-push.c\n+++ b/builtin-push.c\n@@ -124,9 +124,9 @@ static int push_with_options(struct transport *transport, int flags)\n \t\treturn 0;\n \n \tif (nonfastforward && advice_push_nonfastforward) {\n-\t\tprintf(\"To prevent you from losing history, non-fast-forward updates were rejected\\n\"\n-\t\t       \"Merge the remote changes before pushing again.  See the 'Note about\\n\"\n-\t\t       \"fast-forwards' section of 'git push --help' for details.\\n\");\n+\t\tfprintf(stderr, \"To prevent you from losing history, non-fast-forward updates were rejected\\n\"\n+\t\t\t\t\"Merge the remote changes before pushing again.  See the 'Note about\\n\"\n+\t\t\t\t\"fast-forwards' section of 'git push --help' for details.\\n\");\n \t}\n \n \treturn 1;\n-- \n1.7.0.rc1.33.g07cf0f.dirty\n"},{"id":"133998","messageId":"82ed08a77b08dd046be932ad4c08f65136c22c29.1265694627.git.larry@elder-gods.org","threadId":"22579","inReplyTo":"1d1ce7e0ad28fd0cad8d9d7bfeda04ba58be36d4.1265694627.git.larry@elder-gods.org","subject":"[PATCH 2/4] git-push: squelch advice message if in --porcelain mode","fromName":"Larry D'Anna","fromEmail":"larry@elder-gods.org","sentAt":"2010-02-09T05:54:00Z","receivedAt":"2010-02-09T05:54:00Z","isPatch":true,"sender":{"key":"larry@elder-gods.org","avatar":"https://avatars.githubusercontent.com/u/3013304?v=4"},"body":"By default, git-push may give the user a verbose advice message if a ref is\nrejected for not being a fast-forward.  This patch squelches that message for\n--porcelain mode.\n\nSigned-off-by: Larry D'Anna <larry@elder-gods.org>\n---\n builtin-push.c |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-push.c b/builtin-push.c\nindex 0a27072..aacba45 100644\n--- a/builtin-push.c\n+++ b/builtin-push.c\n@@ -226,6 +226,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \tgit_config(git_default_config, NULL);\n \targc = parse_options(argc, argv, prefix, options, push_usage, 0);\n \n+\tif (flags & TRANSPORT_PUSH_PORCELAIN) {\n+\t\t/* Do not give advice messages to Porcelain scripts */\n+\t\tadvice_push_nonfastforward = 0;\n+\t}\n+\n \tif (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))\n \t\tdie(\"--delete is incompatible with --all, --mirror and --tags\");\n \tif (deleterefs && argc < 2)\n-- \n1.7.0.rc1.33.g07cf0f.dirty\n"},{"id":"133999","messageId":"45357037fd8f928759c9e9064736c62e793b84be.1265694627.git.larry@elder-gods.org","threadId":"22579","inReplyTo":"1d1ce7e0ad28fd0cad8d9d7bfeda04ba58be36d4.1265694627.git.larry@elder-gods.org","subject":"[PATCH 3/4] git-push: send \"To <remoteurl>\" messages to the standard output in --porcelain mode","fromName":"Larry D'Anna","fromEmail":"larry@elder-gods.org","sentAt":"2010-02-09T05:54:01Z","receivedAt":"2010-02-09T05:54:01Z","isPatch":true,"sender":{"key":"larry@elder-gods.org","avatar":"https://avatars.githubusercontent.com/u/3013304?v=4"},"body":"git-push prints the line \"To <remoteurl>\" before above each of the ref status\nlines.  In --porcelain mode, these \"To <remoteurl>\" lines go to the standard\nerror, but the ref status lines go to the standard output.  This makes it\ndifficult for the process reading standard output to know which ref status lines\ncorrespond to which remote.  This patch sends the \"To <remoteurl>\" lines to the\nthe standard output instead.\n\nSigned-off-by: Larry D'Anna <larry@elder-gods.org>\n---\n transport.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/transport.c b/transport.c\nindex 3846aac..fb653c6 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -675,7 +675,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)\n static int print_one_push_status(struct ref *ref, const char *dest, int count, int porcelain)\n {\n \tif (!count)\n-\t\tfprintf(stderr, \"To %s\\n\", dest);\n+\t\tfprintf(porcelain ? stdout : stderr, \"To %s\\n\", dest);\n \n \tswitch(ref->status) {\n \tcase REF_STATUS_NONE:\n-- \n1.7.0.rc1.33.g07cf0f.dirty\n"},{"id":"134000","messageId":"d19f6773a0b44d4ec07738727dc474a354c6236d.1265694627.git.larry@elder-gods.org","threadId":"22579","inReplyTo":"1d1ce7e0ad28fd0cad8d9d7bfeda04ba58be36d4.1265694627.git.larry@elder-gods.org","subject":"[PATCH 4/4] git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejected","fromName":"Larry D'Anna","fromEmail":"larry@elder-gods.org","sentAt":"2010-02-09T05:54:02Z","receivedAt":"2010-02-09T05:54:02Z","isPatch":true,"sender":{"key":"larry@elder-gods.org","avatar":"https://avatars.githubusercontent.com/u/3013304?v=4"},"body":"The script calling git push --dry-run --porcelain can see clearly from the\noutput that the updates will be rejected.  However, it will probably need to\ndistinguish this condition from the push failing for other reasons, such as the\nremote not being reachable.\n\nSigned-off-by: Larry D'Anna <larry@elder-gods.org>\n---\n builtin-send-pack.c |    4 ++++\n send-pack.h         |    1 +\n transport.c         |    3 ++-\n 3 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-send-pack.c b/builtin-send-pack.c\nindex 76c7206..358f5e1 100644\n--- a/builtin-send-pack.c\n+++ b/builtin-send-pack.c\n@@ -476,6 +476,10 @@ int send_pack(struct send_pack_args *args,\n \n \tif (ret < 0)\n \t\treturn ret;\n+\n+\tif (args->porcelain && args->dry_run)\n+\t\treturn 0;\n+\n \tfor (ref = remote_refs; ref; ref = ref->next) {\n \t\tswitch (ref->status) {\n \t\tcase REF_STATUS_NONE:\ndiff --git a/send-pack.h b/send-pack.h\nindex 28141ac..60b4ba6 100644\n--- a/send-pack.h\n+++ b/send-pack.h\n@@ -4,6 +4,7 @@\n struct send_pack_args {\n \tunsigned verbose:1,\n \t\tquiet:1,\n+\t\tporcelain:1,\n \t\tsend_mirror:1,\n \t\tforce_update:1,\n \t\tuse_thin_pack:1,\ndiff --git a/transport.c b/transport.c\nindex fb653c6..0edcc16 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -791,6 +791,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re\n \targs.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE);\n \targs.quiet = !!(flags & TRANSPORT_PUSH_QUIET);\n \targs.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);\n+\targs.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);\n \n \tret = send_pack(&args, data->fd, data->conn, remote_refs,\n \t\t\t&data->extra_have);\n@@ -1052,7 +1053,7 @@ int transport_push(struct transport *transport,\n \t\t\tflags & TRANSPORT_PUSH_FORCE);\n \n \t\tret = transport->push_refs(transport, remote_refs, flags);\n-\t\terr = push_had_errors(remote_refs);\n+\t\terr = (pretend && porcelain) ? 0 : push_had_errors(remote_refs);\n \n \t\tret |= err;\n \n-- \n1.7.0.rc1.33.g07cf0f.dirty\n"},{"id":"134270","messageId":"be6fef0d1002111454w10ad965ej72699d1e185d2a9f@mail.gmail.com","threadId":"22579","inReplyTo":"45357037fd8f928759c9e9064736c62e793b84be.1265694627.git.larry@elder-gods.org","subject":"Re: [PATCH 3/4] git-push: send \"To <remoteurl>\" messages to the standard output in --porcelain mode","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-02-11T22:54:47Z","receivedAt":"2010-02-11T22:54:47Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Tue, Feb 9, 2010 at 1:54 PM, Larry D'Anna <larry@elder-gods.org> wrote:\n> diff --git a/transport.c b/transport.c\n> index 3846aac..fb653c6 100644\n> --- a/transport.c\n> +++ b/transport.c\n> @@ -675,7 +675,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)\n>  static int print_one_push_status(struct ref *ref, const char *dest, int count, int porcelain)\n>  {\n>        if (!count)\n> -               fprintf(stderr, \"To %s\\n\", dest);\n> +               fprintf(porcelain ? stdout : stderr, \"To %s\\n\", dest);\n>\n>        switch(ref->status) {\n>        case REF_STATUS_NONE:\n\njust to check - are debug and user-specific messages (like advice and\ninfo) to be sent, by convention/design/force-of-habit, to stderr? Are\nthose the \"cruft\" that has been referred to in other threads?\n\nIf that's the case, then perhaps the \"To: <destination>\" lines should\nbe sent to both stdout and stderr - stdout, for porcelain scripts as a\n\"header\", and stderr, to help the user make sense of any errors that\noccur (\"oh, these errors were triggered when pushing to so-and-so\nremote\").\n\n-- \nCheers,\nRay Chuan\n"},{"id":"134273","messageId":"7veikrs6m1.fsf@alter.siamese.dyndns.org","threadId":"22579","inReplyTo":"be6fef0d1002111454w10ad965ej72699d1e185d2a9f@mail.gmail.com","subject":"Re: [PATCH 3/4] git-push: send \"To <remoteurl>\" messages to the standard output in --porcelain mode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-11T23:19:34Z","receivedAt":"2010-02-11T23:19:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> If that's the case, then perhaps the \"To: <destination>\" lines should\n> be sent to both stdout and stderr - stdout, for porcelain scripts as a\n> \"header\", and stderr, to help the user make sense of any errors that\n> occur (\"oh, these errors were triggered when pushing to so-and-so\n> remote\").\n\nUnder --porcelain, to show or not to show is under control of the calling\nscript.  Not sending it to standard error stream doesn't cause any harm,\nas the calling script can choose to echo it out to its standard error (or\nstandard output).\n"}]}