From: shejialuo <shejialuo@gmail.com>
To: Kousik Sanagavarapu <five231003@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/3] builtin/mailinfo: don't rely on "the_repository"
Date: Wed, 16 Oct 2024 00:14:20 +0800 [thread overview]
Message-ID: <Zw6U3NLlxCFoszMq@ArchLinux> (raw)
In-Reply-To: <20241015144935.4059-4-five231003@gmail.com>
On Tue, Oct 15, 2024 at 08:01:24PM +0530, Kousik Sanagavarapu wrote:
> Change builtin/mailinfo.c so that it doesn't have to rely on
> "the_repository" anymore - hence also allowing us the remove the
> USE_THE_REPOSITORY_VARIABLE guard.
>
> Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
> ---
> builtin/mailinfo.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
> index 828b2b5845..9463a8780a 100644
> --- a/builtin/mailinfo.c
> +++ b/builtin/mailinfo.c
> @@ -2,7 +2,6 @@
> * Another stupid program, this one parsing the headers of an
> * email to figure out authorship and subject
> */
> -#define USE_THE_REPOSITORY_VARIABLE
> #include "builtin.h"
> #include "abspath.h"
> #include "environment.h"
> @@ -52,7 +51,7 @@ static int parse_opt_quoted_cr(const struct option *opt, const char *arg, int un
> int cmd_mailinfo(int argc,
> const char **argv,
> const char *prefix,
> - struct repository *repo UNUSED)
> + struct repository *repo)
> {
> struct metainfo_charset meta_charset;
> struct mailinfo mi;
> @@ -93,8 +92,7 @@ int cmd_mailinfo(int argc,
>
> switch (meta_charset.policy) {
> case CHARSET_DEFAULT:
> - mi.metainfo_charset =
> - repo_get_commit_output_encoding(the_repository);
> + mi.metainfo_charset = repo_get_commit_output_encoding(repo);
This is wrong. We cannot simply pass the "repo" here. As [1] shows, we
will pass "NULL" for "repo" when running "git-mailinfo(1)" outside of
the repo. There is no harm when using "repo_get_commit_output_encoding".
Because this function will check whether "repo" is NULL and it will call
"repo_get_commit_output_encoding" and then return the default value
"UTF-8".
But what if the user has set up the "i18n.logoutputencoding" in the
config file? We will ignore. There are no tests in the current codebase
for running "git-mailinfo(1)" outside of the repo. But we should care
about this.
[1] <d59b85b529865793c652d983d71a9fbb7e16b3e3.1728594828.git.gitgitgadget@gmail.com>
> break;
> case CHARSET_NO_REENCODE:
> mi.metainfo_charset = NULL;
> --
> 2.47.0.73.g7a80afd5fd.dirty
>
>
next prev parent reply other threads:[~2024-10-15 16:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 14:31 [RFC PATCH 0/3] pretty, builtin/mailinfo: don't rely on the_repository Kousik Sanagavarapu
2024-10-15 14:31 ` [PATCH 1/3] repository: move git_*_encoding configs to repo scope Kousik Sanagavarapu
2024-10-15 16:05 ` shejialuo
2024-10-16 6:15 ` Patrick Steinhardt
2024-10-16 17:24 ` Kousik Sanagavarapu
2024-10-17 5:03 ` Patrick Steinhardt
2024-10-17 13:06 ` shejialuo
2024-10-16 16:31 ` Kousik Sanagavarapu
2024-10-15 14:31 ` [PATCH 2/3] pretty: don't rely on "the_repository" Kousik Sanagavarapu
2024-10-15 14:31 ` [PATCH 3/3] builtin/mailinfo: " Kousik Sanagavarapu
2024-10-15 16:14 ` shejialuo [this message]
2024-10-15 19:51 ` [RFC PATCH 0/3] pretty, builtin/mailinfo: don't rely on the_repository Taylor Blau
2024-10-16 17:49 ` Kousik Sanagavarapu
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=Zw6U3NLlxCFoszMq@ArchLinux \
--to=shejialuo@gmail.com \
--cc=five231003@gmail.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;
as well as URLs for NNTP newsgroup(s).