From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH] submodule--helper: do not call utf8_fprintf() unnecessarily
Date: Wed, 28 Jun 2017 13:38:48 -0700 [thread overview]
Message-ID: <xmqq1sq3x2xz.fsf@gitster.mtv.corp.google.com> (raw)
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.
builtin/submodule--helper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 8517032b3e..50c6af1de7 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -326,7 +326,7 @@ static int module_list(int argc, const char **argv, const char *prefix)
printf("%06o %s %d\t", ce->ce_mode,
oid_to_hex(&ce->oid), ce_stage(ce));
- utf8_fprintf(stdout, "%s\n", ce->name);
+ fprintf(stdout, "%s\n", ce->name);
}
return 0;
}
@@ -1038,7 +1038,7 @@ static int update_clone(int argc, const char **argv, const char *prefix)
return 1;
for_each_string_list_item(item, &suc.projectlines)
- utf8_fprintf(stdout, "%s", item->string);
+ fprintf(stdout, "%s", item->string);
return 0;
}
next reply other threads:[~2017-06-28 20:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-28 20:38 Junio C Hamano [this message]
2017-06-28 20:44 ` [PATCH] submodule--helper: do not call utf8_fprintf() unnecessarily Stefan Beller
2017-06-28 20:58 ` Junio C Hamano
2017-06-28 21:18 ` Stefan Beller
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=xmqq1sq3x2xz.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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