{"thread":{"id":"22536","subject":"[PATCH v2 1/3] fix an error message in git-push so it goes to stderr","startedAt":"2010-02-05T20:49:38Z","lastAt":"2010-02-08T20:19:56Z","messageCount":7,"participants":["Larry D'Anna","Junio C Hamano","Tay Ray Chuan"],"isPatch":true,"patchVersion":2,"patchTotal":3},"messages":[{"id":"133718","messageId":"cover.1265402797.git.larry@elder-gods.org","threadId":"22536","inReplyTo":"7v1vgz5ta7.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2 0/3]","fromName":"Larry D'Anna","fromEmail":"larry@elder-gods.org","sentAt":"2010-02-05T20:49:38Z","receivedAt":"2010-02-05T20:49:38Z","isPatch":true,"sender":{"key":"larry@elder-gods.org","avatar":"https://avatars.githubusercontent.com/u/3013304?v=4"},"body":"I've fixed his series according to Jeff' and Junio's comments.\n\nLarry D'Anna (3):\n  fix an error message in git-push so it goes to stderr\n  clean up some of the output from git push --porcelain\n  make git push --dry-run --porcelain exit with status 0 even if\n    updates will be rejected\n\n builtin-push.c      |    8 ++++----\n builtin-send-pack.c |    4 ++++\n send-pack.h         |    1 +\n transport.c         |   11 +++++++----\n 4 files changed, 16 insertions(+), 8 deletions(-)\n"},{"id":"133716","messageId":"c48cda45fbbc257debb737818137a5bd01a8bc5c.1265402797.git.larry@elder-gods.org","threadId":"22536","inReplyTo":"cover.1265402797.git.larry@elder-gods.org","subject":"[PATCH v2 1/3] fix an error message in git-push so it goes to stderr","fromName":"Larry D'Anna","fromEmail":"larry@elder-gods.org","sentAt":"2010-02-05T20:49:39Z","receivedAt":"2010-02-05T20:49:39Z","isPatch":true,"sender":{"key":"larry@elder-gods.org","avatar":"https://avatars.githubusercontent.com/u/3013304?v=4"},"body":"Having it go to standard output interferes with git-push --porcelain.\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":"133717","messageId":"ec0db70b8166ee4093a5a2400cd592e4263db20b.1265402797.git.larry@elder-gods.org","threadId":"22536","inReplyTo":"cover.1265402797.git.larry@elder-gods.org","subject":"[PATCH v2 2/3] clean up some of the output from git push --porcelain","fromName":"Larry D'Anna","fromEmail":"larry@elder-gods.org","sentAt":"2010-02-05T20:49:40Z","receivedAt":"2010-02-05T20:49:40Z","isPatch":true,"sender":{"key":"larry@elder-gods.org","avatar":"https://avatars.githubusercontent.com/u/3013304?v=4"},"body":"* don't emit long explanatory message about non-fast-forward updates.\n\n* send \"To dest\" lines to standard out so whoever is reading standard out knows\n  which ref updates went to which remotes.\n\n* only send the \"Everything up-to-date\" line if verbose.\n\nSigned-off-by: Larry D'Anna <larry@elder-gods.org>\n---\n builtin-push.c |    2 +-\n transport.c    |    4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-push.c b/builtin-push.c\nindex 0a27072..ff0b1c6 100644\n--- a/builtin-push.c\n+++ b/builtin-push.c\n@@ -123,7 +123,7 @@ static int push_with_options(struct transport *transport, int flags)\n \tif (!err)\n \t\treturn 0;\n \n-\tif (nonfastforward && advice_push_nonfastforward) {\n+\tif (!(flags & TRANSPORT_PUSH_PORCELAIN) && nonfastforward && advice_push_nonfastforward) {\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\");\ndiff --git a/transport.c b/transport.c\nindex 3846aac..00d986c 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@@ -1070,7 +1070,7 @@ int transport_push(struct transport *transport,\n \t\t\t\tupdate_tracking_ref(transport->remote, ref, verbose);\n \t\t}\n \n-\t\tif (!quiet && !ret && !refs_pushed(remote_refs))\n+\t\tif (!quiet && (!porcelain || verbose) && !ret && !refs_pushed(remote_refs))\n \t\t\tfprintf(stderr, \"Everything up-to-date\\n\");\n \t\treturn ret;\n \t}\n-- \n1.7.0.rc1.33.g07cf0f.dirty\n"},{"id":"133719","messageId":"cea7001d626116d76d885e24152d68cf41eca4dd.1265402797.git.larry@elder-gods.org","threadId":"22536","inReplyTo":"cover.1265402797.git.larry@elder-gods.org","subject":"[PATCH v2 3/3] 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-05T20:49:41Z","receivedAt":"2010-02-05T20:49:41Z","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         |    7 +++++--\n 3 files changed, 10 insertions(+), 2 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 00d986c..b41e1dc 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -558,8 +558,10 @@ static int fetch_refs_via_pack(struct transport *transport,\n \treturn (refs ? 0 : -1);\n }\n \n-static int push_had_errors(struct ref *ref)\n+static int push_had_errors(struct ref *ref, int flags)\n {\n+\tif (flags & TRANSPORT_PUSH_DRY_RUN && flags & TRANSPORT_PUSH_PORCELAIN)\n+\t\treturn 0;\n \tfor (; ref; ref = ref->next) {\n \t\tswitch (ref->status) {\n \t\tcase REF_STATUS_NONE:\n@@ -791,6 +793,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 +1055,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 = push_had_errors(remote_refs, flags);\n \n \t\tret |= err;\n \n-- \n1.7.0.rc1.33.g07cf0f.dirty\n"},{"id":"133726","messageId":"7vpr4j1jeq.fsf@alter.siamese.dyndns.org","threadId":"22536","inReplyTo":"ec0db70b8166ee4093a5a2400cd592e4263db20b.1265402797.git.larry@elder-gods.org","subject":"Re: [PATCH v2 2/3] clean up some of the output from git push --porcelain","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-05T21:07:09Z","receivedAt":"2010-02-05T21:07:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Larry D'Anna <larry@elder-gods.org> writes:\n\n> diff --git a/builtin-push.c b/builtin-push.c\n> index 0a27072..ff0b1c6 100644\n> --- a/builtin-push.c\n> +++ b/builtin-push.c\n> @@ -123,7 +123,7 @@ static int push_with_options(struct transport *transport, int flags)\n>  \tif (!err)\n>  \t\treturn 0;\n>  \n> -\tif (nonfastforward && advice_push_nonfastforward) {\n> +\tif (!(flags & TRANSPORT_PUSH_PORCELAIN) && nonfastforward && advice_push_nonfastforward) {\n\nI suspect that it would be a much nicer solution if you turned advice_*\noff in very early parts of the codepath after you read configuration and\ncommand line options to see if --porcelain was asked for.  That way, we\ndon't have to add code check for PORCELAIN next time we add code for new\nkinds of advice.  People who are adding new advice_* would grep for\nexisting one (e.g. \"advice_push_nonfastforward\") and will notice this\nline, but if you had\n\n\tif (flags & TRANSPORT_PUSH_PORDCELAIN) {\n        \tadvice_push_nonfastforward = 0;\n\t}\n\nin early parts of the code, they will notice that as well, and then they\nknow where to add the corresponding change necessary.\n"},{"id":"133760","messageId":"20100206075025.c1fe6b5a.rctay89@gmail.com","threadId":"22536","inReplyTo":"cea7001d626116d76d885e24152d68cf41eca4dd.1265402797.git.larry@elder-gods.org","subject":"Re: [PATCH v2 3/3] make git push --dry-run --porcelain exit with status 0 even if updates will be rejected","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-02-05T23:50:25Z","receivedAt":"2010-02-05T23:50:25Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\ninstead of:\n\n> diff --git a/transport.c b/transport.c\n> index 00d986c..b41e1dc 100644\n> --- a/transport.c\n> +++ b/transport.c\n> @@ -558,8 +558,10 @@ static int fetch_refs_via_pack(struct transport *transport,\n>  \treturn (refs ? 0 : -1);\n>  }\n>  \n> -static int push_had_errors(struct ref *ref)\n> +static int push_had_errors(struct ref *ref, int flags)\n>  {\n> +\tif (flags & TRANSPORT_PUSH_DRY_RUN && flags & TRANSPORT_PUSH_PORCELAIN)\n> +\t\treturn 0;\n>  \tfor (; ref; ref = ref->next) {\n>  \t\tswitch (ref->status) {\n>  \t\tcase REF_STATUS_NONE:\n\nand:\n\n> @@ -1052,7 +1055,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 = push_had_errors(remote_refs, flags);\n>  \n>  \t\tret |= err;\n>  \n\nwhy not:\n\n-->8--\n@@ -1049,7 +1052,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-->8--\n\n-- \nCheers,\nRay Chuan\n"},{"id":"133943","messageId":"20100208201956.GA7015@cthulhu","threadId":"22536","inReplyTo":"20100206075025.c1fe6b5a.rctay89@gmail.com","subject":"Re: [PATCH v2 3/3] 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-08T20:19:56Z","receivedAt":"2010-02-08T20:19:56Z","isPatch":true,"sender":{"key":"larry@elder-gods.org","avatar":"https://avatars.githubusercontent.com/u/3013304?v=4"},"body":"\ngood idea.  \n\n     --larry\n"}]}