git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH] submodule--helper: do not call utf8_fprintf() unnecessarily
Date: Wed, 28 Jun 2017 14:18:24 -0700	[thread overview]
Message-ID: <CAGZ79kY++zFEGDZhPMQebbGBw7UXjUf6f+bOzZ58_5NLQpCcjg@mail.gmail.com> (raw)
In-Reply-To: <xmqqwp7vvngg.fsf@gitster.mtv.corp.google.com>

On Wed, Jun 28, 2017 at 1:58 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>> On Wed, Jun 28, 2017 at 1:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> The helper function utf8_fprintf(fp, ...) has exactly the same
>>> effect to the output stream fp as fprintf(fp, ...) does, and the
>>> only difference is that its return value counts in display columns
>>> consumed (assuming that the payload is encoded in UTF-8), as opposed
>>> to number of bytes.
>>>
>>> There is no reason to call it unless the caller cares about its
>>> return value.
>>>
>>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>>> ---
>>>
>>>  * The helper was introduced at c0821965 ("Add utf8_fprintf helper
>>>    that returns correct number of columns", 2013-02-09), which also
>>>    taught the help text output from the parse_options API to use it
>>>    to align columns.  These original callers naturally do use the
>>>    returned value and left alone by this fix, which corrects all the
>>>    later callers that misuses it.
>>>
>>
>> The patch looks correct.

I said this because I had a similar implementation a couple weeks back
when Peff tried to poke (security) holes into submodule usage.

I tried finding the reason why it was originally introduced, but to no avail.
It seems to be randomly introduced.

> Thanks.  I had a small voice back in my head telling me that I may
> have misread the code and this patch breaks things, which you
> cleared up for me ;-)

That said, #include "utf8.h" could also go from the file with this
or after this patch, I believe.

      reply	other threads:[~2017-06-28 21:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28 20:38 [PATCH] submodule--helper: do not call utf8_fprintf() unnecessarily Junio C Hamano
2017-06-28 20:44 ` Stefan Beller
2017-06-28 20:58   ` Junio C Hamano
2017-06-28 21:18     ` Stefan Beller [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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CAGZ79kY++zFEGDZhPMQebbGBw7UXjUf6f+bOzZ58_5NLQpCcjg@mail.gmail.com \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).