git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Peart <peartben@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Cc: Christian Couder <christian.couder@gmail.com>,
	Jeff King <peff@peff.net>, Ben Peart <Ben.Peart@microsoft.com>,
	Jonathan Tan <jonathantanmy@google.com>,
	Lars Schneider <larsxschneider@gmail.com>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH v2] sub-process: print the cmd when a capability is unsupported
Date: Mon, 11 Sep 2017 08:34:41 -0400	[thread overview]
Message-ID: <29df9cf1-c75e-9d0f-7163-aee4ebec4527@gmail.com> (raw)
In-Reply-To: <xmqqlgll5300.fsf@gitster.mtv.corp.google.com>



On 9/10/2017 11:27 PM, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> I still think we would want to turn warning() to die(), but it
>> probably is better to do so in a separate follow-up patch.  That
>> will give us a good place to record the reason why the current "just
>> call a warning() and pretend as if nothing bad happend" is wrong.
> 
> And here is such an update.  It seems that pretty much all comments
> in the original thread were "warning is wrong--we should die here",
> but nobody seems to have bothered following it through.
> 
> cf. <20170815111725.5d009b66@twelve2.svl.corp.google.com>
> 
> -- >8 --
> Subject: [PATCH] subprocess: loudly die when subprocess asks for an unsupported capability
> 
> The handshake_capabilities() function first advertises the set of
> capabilities it supports, so that the other side can pick and choose
> which ones to use and ask us to enable in its response.  Then we
> read the response that tells us what choice the other side made.  If
> we saw something that we never advertised, that indicates one of two
> things.  The other side, i.e. the "upgraded" filter, is not paying
> attention of the capabilities advertisement, and asking something
> its correct operation relies on, but we are not capable of giving
> that unknown feature and operate without it, so after that point the
> exchange of data is a garbage-in-garbage-out.  Or the other side
> wanted to ask for one of the capabilities we advertised, but the
> code has typo and their wish to enable a capability that its correct
> operation relies on is not understood on this end.  The result is
> the same garbage-in-garbage-out.
> 
> Instead of sweeping such a potential bug under the rug, die loudly
> when we see a request for an unsupported capability in order to
> force sloppily-written filter scripts to get corrected.
> 

The documentation states "Git expects to read a list of desired
capabilities, ***which must be a subset of the supported capabilities 
list*** and a flush packet as response:"

Anything else is clearly a bug so a "die" is more appropriate than a 
warning.

Patch looks good.  Thanks for making sure this didn't fall through the 
cracks.

> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>   sub-process.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sub-process.c b/sub-process.c
> index fcc4832c14..ec9a51b7b1 100644
> --- a/sub-process.c
> +++ b/sub-process.c
> @@ -181,8 +181,8 @@ static int handshake_capabilities(struct child_process *process,
>   			if (supported_capabilities)
>   				*supported_capabilities |= capabilities[i].flag;
>   		} else {
> -			warning("subprocess '%s' requested unsupported capability '%s'",
> -				process->argv[0], p);
> +			die("subprocess '%s' requested unsupported capability '%s'",
> +			    process->argv[0], p);
>   		}
>   	}
>   
> 

  reply	other threads:[~2017-09-11 12:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16 12:40 [PATCH v2] sub-process: print the cmd when a capability is unsupported Christian Couder
2017-08-16 14:06 ` Ben Peart
2017-08-16 16:41   ` Junio C Hamano
2017-08-16 21:55     ` Junio C Hamano
2017-09-11  3:27       ` Junio C Hamano
2017-09-11 12:34         ` Ben Peart [this message]
2017-09-12 12:02         ` Lars Schneider
2017-08-16 15:48 ` Lars Schneider

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=29df9cf1-c75e-9d0f-7163-aee4ebec4527@gmail.com \
    --to=peartben@gmail.com \
    --cc=Ben.Peart@microsoft.com \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    --cc=jrnieder@gmail.com \
    --cc=larsxschneider@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).