{"thread":{"id":"46605","subject":"[PATCH v2] sub-process: print the cmd when a capability is unsupported","startedAt":"2017-08-16T12:40:51Z","lastAt":"2017-09-12T12:02:49Z","messageCount":8,"participants":["Christian Couder","Ben Peart","Lars Schneider","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"326504","messageId":"20170816124036.25236-1-chriscool@tuxfamily.org","threadId":"46605","inReplyTo":null,"subject":"[PATCH v2] sub-process: print the cmd when a capability is unsupported","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2017-08-16T12:40:36Z","receivedAt":"2017-08-16T12:40:51Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"In handshake_capabilities() we use warning() when a capability\nis not supported, so the exit code of the function is 0 and no\nfurther error is shown. This is a problem because the warning\nmessage doesn't tell us which subprocess cmd failed.\n\nOn the contrary if we cannot write a packet from this function,\nwe use error() and then subprocess_start() outputs:\n\n    initialization for subprocess '<cmd>' failed\n\nso we can know which subprocess cmd failed.\n\nLet's improve the warning() message, so that we can know which\nsubprocess cmd failed.\n\nHelped-by: Lars Schneider <larsxschneider@gmail.com>\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\nChange since previous version:\n\n  - Use process->argv[0] instead of adding a new parameter to\n    handshake_capabilities(), thanks to Lars.\n\n sub-process.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/sub-process.c b/sub-process.c\nindex 6edb97c1c6..6ccfaaba99 100644\n--- a/sub-process.c\n+++ b/sub-process.c\n@@ -184,8 +184,8 @@ static int handshake_capabilities(struct child_process *process,\n \t\t\tif (supported_capabilities)\n \t\t\t\t*supported_capabilities |= capabilities[i].flag;\n \t\t} else {\n-\t\t\twarning(\"external filter requested unsupported filter capability '%s'\",\n-\t\t\t\tp);\n+\t\t\twarning(\"subprocess '%s' requested unsupported capability '%s'\",\n+\t\t\t\tprocess->argv[0], p);\n \t\t}\n \t}\n \n-- \n2.14.1.146.g7de11f915a\n\n"},{"id":"326507","messageId":"758d36a7-8066-7e1a-30d0-62baf2796520@gmail.com","threadId":"46605","inReplyTo":"20170816124036.25236-1-chriscool@tuxfamily.org","subject":"Re: [PATCH v2] sub-process: print the cmd when a capability is unsupported","fromName":"Ben Peart","fromEmail":"peartben@gmail.com","sentAt":"2017-08-16T14:06:18Z","receivedAt":"2017-08-16T14:06:27Z","isPatch":true,"sender":{"key":"benpeart@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/15252029?v=4"},"body":"\n\nOn 8/16/2017 8:40 AM, Christian Couder wrote:\n> In handshake_capabilities() we use warning() when a capability\n> is not supported, so the exit code of the function is 0 and no\n> further error is shown. This is a problem because the warning\n> message doesn't tell us which subprocess cmd failed.\n> \n> On the contrary if we cannot write a packet from this function,\n> we use error() and then subprocess_start() outputs:\n> \n>      initialization for subprocess '<cmd>' failed\n> \n> so we can know which subprocess cmd failed.\n> \n> Let's improve the warning() message, so that we can know which\n> subprocess cmd failed.\n> \n> Helped-by: Lars Schneider <larsxschneider@gmail.com>\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n> Change since previous version:\n> \n>    - Use process->argv[0] instead of adding a new parameter to\n>      handshake_capabilities(), thanks to Lars.\n> \n>   sub-process.c | 4 ++--\n>   1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/sub-process.c b/sub-process.c\n> index 6edb97c1c6..6ccfaaba99 100644\n> --- a/sub-process.c\n> +++ b/sub-process.c\n> @@ -184,8 +184,8 @@ static int handshake_capabilities(struct child_process *process,\n>   \t\t\tif (supported_capabilities)\n>   \t\t\t\t*supported_capabilities |= capabilities[i].flag;\n>   \t\t} else {\n> -\t\t\twarning(\"external filter requested unsupported filter capability '%s'\",\n> -\t\t\t\tp);\n> +\t\t\twarning(\"subprocess '%s' requested unsupported capability '%s'\",\n> +\t\t\t\tprocess->argv[0], p);\n>   \t\t}\n>   \t}\n>   \n> \n\nThis one is even cleaner.  Thanks Lars for pointing out the fact we \nalready had the cmd name.  Looks good.\n"},{"id":"326508","messageId":"C7814B93-B103-4D77-B815-2AFC1A9CB566@gmail.com","threadId":"46605","inReplyTo":"20170816124036.25236-1-chriscool@tuxfamily.org","subject":"Re: [PATCH v2] sub-process: print the cmd when a capability is unsupported","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2017-08-16T15:48:47Z","receivedAt":"2017-08-16T15:48:57Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\n> On 16 Aug 2017, at 14:40, Christian Couder <christian.couder@gmail.com> wrote:\n> \n> In handshake_capabilities() we use warning() when a capability\n> is not supported, so the exit code of the function is 0 and no\n> further error is shown. This is a problem because the warning\n> message doesn't tell us which subprocess cmd failed.\n> \n> On the contrary if we cannot write a packet from this function,\n> we use error() and then subprocess_start() outputs:\n> \n>    initialization for subprocess '<cmd>' failed\n> \n> so we can know which subprocess cmd failed.\n> \n> Let's improve the warning() message, so that we can know which\n> subprocess cmd failed.\n> \n> Helped-by: Lars Schneider <larsxschneider@gmail.com>\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n> Change since previous version:\n> \n>  - Use process->argv[0] instead of adding a new parameter to\n>    handshake_capabilities(), thanks to Lars.\n> \n> sub-process.c | 4 ++--\n> 1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/sub-process.c b/sub-process.c\n> index 6edb97c1c6..6ccfaaba99 100644\n> --- a/sub-process.c\n> +++ b/sub-process.c\n> @@ -184,8 +184,8 @@ static int handshake_capabilities(struct child_process *process,\n> \t\t\tif (supported_capabilities)\n> \t\t\t\t*supported_capabilities |= capabilities[i].flag;\n> \t\t} else {\n> -\t\t\twarning(\"external filter requested unsupported filter capability '%s'\",\n> -\t\t\t\tp);\n> +\t\t\twarning(\"subprocess '%s' requested unsupported capability '%s'\",\n> +\t\t\t\tprocess->argv[0], p);\n> \t\t}\n> \t}\n> \n> -- \n> 2.14.1.146.g7de11f915a\n> \n\nLooks good to me.\n\nThanks,\nLars"},{"id":"326512","messageId":"xmqq4lt7pir9.fsf@gitster.mtv.corp.google.com","threadId":"46605","inReplyTo":"758d36a7-8066-7e1a-30d0-62baf2796520@gmail.com","subject":"Re: [PATCH v2] sub-process: print the cmd when a capability is unsupported","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-16T16:41:46Z","receivedAt":"2017-08-16T16:41:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Peart <peartben@gmail.com> writes:\n\n>> -\t\t\twarning(\"external filter requested unsupported filter capability '%s'\",\n>> -\t\t\t\tp);\n>> +\t\t\twarning(\"subprocess '%s' requested unsupported capability '%s'\",\n>> +\t\t\t\tprocess->argv[0], p);\n>>   \t\t}\n>>   \t}\n>>   \n>>\n>\n> This one is even cleaner.  Thanks Lars for pointing out the fact we\n> already had the cmd name.  Looks good.\n\nThanks, all.  Will queue.\n\n\n"},{"id":"326564","messageId":"xmqqshgri3dv.fsf@gitster.mtv.corp.google.com","threadId":"46605","inReplyTo":"xmqq4lt7pir9.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] sub-process: print the cmd when a capability is unsupported","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-16T21:55:40Z","receivedAt":"2017-08-16T21:55:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Ben Peart <peartben@gmail.com> writes:\n>\n>>> -\t\t\twarning(\"external filter requested unsupported filter capability '%s'\",\n>>> -\t\t\t\tp);\n>>> +\t\t\twarning(\"subprocess '%s' requested unsupported capability '%s'\",\n>>> +\t\t\t\tprocess->argv[0], p);\n>>>   \t\t}\n>>>   \t}\n>>>   \n>>>\n>>\n>> This one is even cleaner.  Thanks Lars for pointing out the fact we\n>> already had the cmd name.  Looks good.\n>\n> Thanks, all.  Will queue.\n\nI still think we would want to turn warning() to die(), but it\nprobably is better to do so in a separate follow-up patch.  That\nwill give us a good place to record the reason why the current \"just\ncall a warning() and pretend as if nothing bad happend\" is wrong.\n\n"},{"id":"327841","messageId":"xmqqlgll5300.fsf@gitster.mtv.corp.google.com","threadId":"46605","inReplyTo":"xmqqshgri3dv.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] sub-process: print the cmd when a capability is unsupported","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-09-11T03:27:11Z","receivedAt":"2017-09-11T03:27:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I still think we would want to turn warning() to die(), but it\n> probably is better to do so in a separate follow-up patch.  That\n> will give us a good place to record the reason why the current \"just\n> call a warning() and pretend as if nothing bad happend\" is wrong.\n\nAnd here is such an update.  It seems that pretty much all comments\nin the original thread were \"warning is wrong--we should die here\",\nbut nobody seems to have bothered following it through.\n\ncf. <20170815111725.5d009b66@twelve2.svl.corp.google.com>\n\n-- >8 --\nSubject: [PATCH] subprocess: loudly die when subprocess asks for an unsupported capability\n\nThe handshake_capabilities() function first advertises the set of\ncapabilities it supports, so that the other side can pick and choose\nwhich ones to use and ask us to enable in its response.  Then we\nread the response that tells us what choice the other side made.  If\nwe saw something that we never advertised, that indicates one of two\nthings.  The other side, i.e. the \"upgraded\" filter, is not paying\nattention of the capabilities advertisement, and asking something\nits correct operation relies on, but we are not capable of giving\nthat unknown feature and operate without it, so after that point the\nexchange of data is a garbage-in-garbage-out.  Or the other side\nwanted to ask for one of the capabilities we advertised, but the\ncode has typo and their wish to enable a capability that its correct\noperation relies on is not understood on this end.  The result is\nthe same garbage-in-garbage-out.\n\nInstead of sweeping such a potential bug under the rug, die loudly\nwhen we see a request for an unsupported capability in order to\nforce sloppily-written filter scripts to get corrected.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n sub-process.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/sub-process.c b/sub-process.c\nindex fcc4832c14..ec9a51b7b1 100644\n--- a/sub-process.c\n+++ b/sub-process.c\n@@ -181,8 +181,8 @@ static int handshake_capabilities(struct child_process *process,\n \t\t\tif (supported_capabilities)\n \t\t\t\t*supported_capabilities |= capabilities[i].flag;\n \t\t} else {\n-\t\t\twarning(\"subprocess '%s' requested unsupported capability '%s'\",\n-\t\t\t\tprocess->argv[0], p);\n+\t\t\tdie(\"subprocess '%s' requested unsupported capability '%s'\",\n+\t\t\t    process->argv[0], p);\n \t\t}\n \t}\n \n-- \n2.14.1-660-g2f12cdf511\n\n"},{"id":"327849","messageId":"29df9cf1-c75e-9d0f-7163-aee4ebec4527@gmail.com","threadId":"46605","inReplyTo":"xmqqlgll5300.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] sub-process: print the cmd when a capability is unsupported","fromName":"Ben Peart","fromEmail":"peartben@gmail.com","sentAt":"2017-09-11T12:34:41Z","receivedAt":"2017-09-11T12:34:51Z","isPatch":true,"sender":{"key":"benpeart@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/15252029?v=4"},"body":"\n\nOn 9/10/2017 11:27 PM, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>> I still think we would want to turn warning() to die(), but it\n>> probably is better to do so in a separate follow-up patch.  That\n>> will give us a good place to record the reason why the current \"just\n>> call a warning() and pretend as if nothing bad happend\" is wrong.\n> \n> And here is such an update.  It seems that pretty much all comments\n> in the original thread were \"warning is wrong--we should die here\",\n> but nobody seems to have bothered following it through.\n> \n> cf. <20170815111725.5d009b66@twelve2.svl.corp.google.com>\n> \n> -- >8 --\n> Subject: [PATCH] subprocess: loudly die when subprocess asks for an unsupported capability\n> \n> The handshake_capabilities() function first advertises the set of\n> capabilities it supports, so that the other side can pick and choose\n> which ones to use and ask us to enable in its response.  Then we\n> read the response that tells us what choice the other side made.  If\n> we saw something that we never advertised, that indicates one of two\n> things.  The other side, i.e. the \"upgraded\" filter, is not paying\n> attention of the capabilities advertisement, and asking something\n> its correct operation relies on, but we are not capable of giving\n> that unknown feature and operate without it, so after that point the\n> exchange of data is a garbage-in-garbage-out.  Or the other side\n> wanted to ask for one of the capabilities we advertised, but the\n> code has typo and their wish to enable a capability that its correct\n> operation relies on is not understood on this end.  The result is\n> the same garbage-in-garbage-out.\n> \n> Instead of sweeping such a potential bug under the rug, die loudly\n> when we see a request for an unsupported capability in order to\n> force sloppily-written filter scripts to get corrected.\n> \n\nThe documentation states \"Git expects to read a list of desired\ncapabilities, ***which must be a subset of the supported capabilities \nlist*** and a flush packet as response:\"\n\nAnything else is clearly a bug so a \"die\" is more appropriate than a \nwarning.\n\nPatch looks good.  Thanks for making sure this didn't fall through the \ncracks.\n\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>   sub-process.c | 4 ++--\n>   1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/sub-process.c b/sub-process.c\n> index fcc4832c14..ec9a51b7b1 100644\n> --- a/sub-process.c\n> +++ b/sub-process.c\n> @@ -181,8 +181,8 @@ static int handshake_capabilities(struct child_process *process,\n>   \t\t\tif (supported_capabilities)\n>   \t\t\t\t*supported_capabilities |= capabilities[i].flag;\n>   \t\t} else {\n> -\t\t\twarning(\"subprocess '%s' requested unsupported capability '%s'\",\n> -\t\t\t\tprocess->argv[0], p);\n> +\t\t\tdie(\"subprocess '%s' requested unsupported capability '%s'\",\n> +\t\t\t    process->argv[0], p);\n>   \t\t}\n>   \t}\n>   \n> \n"},{"id":"327887","messageId":"EE6D0955-424A-4330-99FA-64B6A82E048B@gmail.com","threadId":"46605","inReplyTo":"xmqqlgll5300.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] sub-process: print the cmd when a capability is unsupported","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2017-09-12T12:02:41Z","receivedAt":"2017-09-12T12:02:49Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\n> On 11 Sep 2017, at 05:27, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>> I still think we would want to turn warning() to die(), but it\n>> probably is better to do so in a separate follow-up patch.  That\n>> will give us a good place to record the reason why the current \"just\n>> call a warning() and pretend as if nothing bad happend\" is wrong.\n> \n> And here is such an update.  It seems that pretty much all comments\n> in the original thread were \"warning is wrong--we should die here\",\n> but nobody seems to have bothered following it through.\n> \n> cf. <20170815111725.5d009b66@twelve2.svl.corp.google.com>\n> \n> -- >8 --\n> Subject: [PATCH] subprocess: loudly die when subprocess asks for an unsupported capability\n> \n> The handshake_capabilities() function first advertises the set of\n> capabilities it supports, so that the other side can pick and choose\n> which ones to use and ask us to enable in its response.  Then we\n> read the response that tells us what choice the other side made.  If\n> we saw something that we never advertised, that indicates one of two\n> things.  The other side, i.e. the \"upgraded\" filter, is not paying\n> attention of the capabilities advertisement, and asking something\n> its correct operation relies on, but we are not capable of giving\n> that unknown feature and operate without it, so after that point the\n> exchange of data is a garbage-in-garbage-out.  Or the other side\n> wanted to ask for one of the capabilities we advertised, but the\n> code has typo and their wish to enable a capability that its correct\n> operation relies on is not understood on this end.  The result is\n> the same garbage-in-garbage-out.\n> \n> Instead of sweeping such a potential bug under the rug, die loudly\n> when we see a request for an unsupported capability in order to\n> force sloppily-written filter scripts to get corrected.\n> \n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n> sub-process.c | 4 ++--\n> 1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/sub-process.c b/sub-process.c\n> index fcc4832c14..ec9a51b7b1 100644\n> --- a/sub-process.c\n> +++ b/sub-process.c\n> @@ -181,8 +181,8 @@ static int handshake_capabilities(struct child_process *process,\n> \t\t\tif (supported_capabilities)\n> \t\t\t\t*supported_capabilities |= capabilities[i].flag;\n> \t\t} else {\n> -\t\t\twarning(\"subprocess '%s' requested unsupported capability '%s'\",\n> -\t\t\t\tprocess->argv[0], p);\n> +\t\t\tdie(\"subprocess '%s' requested unsupported capability '%s'\",\n> +\t\t\t    process->argv[0], p);\n\nLooks good! \n\nThank you,\nLars"}]}