git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Erik Faye-Lund <kusmabite@gmail.com>, git@vger.kernel.org
Subject: Re: [PATH/RFC] parse-options: report invalid UTF-8 switches
Date: Mon, 11 Feb 2013 09:54:08 -0800	[thread overview]
Message-ID: <7vy5eun3cv.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130211171957.GG16402@sigill.intra.peff.net> (Jeff King's message of "Mon, 11 Feb 2013 12:19:57 -0500")

Jeff King <peff@peff.net> writes:

> On Mon, Feb 11, 2013 at 09:07:53AM -0800, Junio C Hamano wrote:
>
>> Erik Faye-Lund <kusmabite@gmail.com> writes:
>> 
>> > However, since git only looks at one byte at the time for
>> > short-options, it ends up reporting a partial UTF-8 sequence
>> > in such cases, leading to corruption of the output.
>> 
>> Isn't it a workable, easier and more robust alternative to punt and
>> use the entire ctx.argv[0] as unrecognized?
>
> Yes, but it regresses the usability:
>
>   [before]
>   $ git foobar -qrxs
>   unknown switch: x
>
>   [after]
>   $ git foobar -qrxs
>   unknown switch: -qrxs
>
> One is much more informative than the other, and you are punishing the
> common ascii case for the extremely uncommon case of utf-8. Maybe:
>
>   if (isascii(*ctx.opt))
>           error("unknown option `%c'", *ctx.opt);
>   else
>           error("unknown multi-byte short option in string: `%s'", ctx.argv[0]);
>
> which only kicks in in the uncommon case (and extends the error message
> to make it more clear why we are showing the whole string).

Yup, that is what I meant.

      parent reply	other threads:[~2013-02-11 17:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-11 13:34 [PATH/RFC] parse-options: report invalid UTF-8 switches Erik Faye-Lund
2013-02-11 13:43 ` Matthieu Moy
2013-02-11 13:57   ` Erik Faye-Lund
2013-02-11 14:05     ` Matthieu Moy
2013-02-11 14:27       ` Erik Faye-Lund
2013-02-11 16:28 ` Torsten Bögershausen
2013-02-11 16:36   ` Erik Faye-Lund
2013-02-11 17:04     ` Torsten Bögershausen
2013-02-11 17:07 ` Junio C Hamano
2013-02-11 17:15   ` Erik Faye-Lund
2013-02-11 17:19   ` Jeff King
2013-02-11 17:21     ` Erik Faye-Lund
2013-02-11 17:54     ` Junio C Hamano [this message]

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=7vy5eun3cv.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@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).