All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Dima Kov via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Dima Kov <dima.kovol@gmail.com>
Subject: Re: [PATCH] refactor of git_setup_gettext method
Date: Mon, 31 May 2021 10:54:51 +0900	[thread overview]
Message-ID: <xmqqbl8r1xck.fsf@gitster.g> (raw)
In-Reply-To: pull.964.git.1622410962551.gitgitgadget@gmail.com

"Dima Kov via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Dima Kov <dima.kovol@gmail.com>
> Subject: Re: [PATCH] refactor of git_setup_gettext method

We do not write in C++, so "method" -> "function".

> Use one "free" call at the end of the function,
> instead of being dependent on the execution flow.
>
> Signed-off-by: Dima Kov <dima.kovol@gmail.com>
> ---

I think an early return is more readable, but if this were a new
code and used the style used in this patch, it would also have been
acceptable.  IOW, this is probably a borderline "Meh" change,
belonging to "what's already commited is good enough and it is not
worth the brain cycles to swap it around" category.


>  gettext.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/gettext.c b/gettext.c
> index af2413b47e85..e75c7bfdb1a8 100644
> --- a/gettext.c
> +++ b/gettext.c
> @@ -109,17 +109,14 @@ void git_setup_gettext(void)
>  	if (!podir)
>  		podir = p = system_path(GIT_LOCALE_PATH);
>  
> -	if (!is_directory(podir)) {
> -		free(p);
> -		return;
> +	if (is_directory(podir)) {
> +		bindtextdomain("git", podir);
> +		setlocale(LC_MESSAGES, "");
> +		setlocale(LC_TIME, "");
> +		init_gettext_charset("git");
> +		textdomain("git");
>  	}
>  
> -	bindtextdomain("git", podir);
> -	setlocale(LC_MESSAGES, "");
> -	setlocale(LC_TIME, "");
> -	init_gettext_charset("git");
> -	textdomain("git");
> -
>  	free(p);
>  }
>  
>
> base-commit: de88ac70f3a801262eb3aa087e5d9a712be0a54a

  parent reply	other threads:[~2021-05-31  1:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-30 21:42 [PATCH] refactor of git_setup_gettext method Dima Kov via GitGitGadget
2021-05-30 22:14 ` Eric Sunshine
2021-05-31  1:54 ` Junio C Hamano [this message]
2021-05-31  3:42 ` Bagas Sanjaya

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=xmqqbl8r1xck.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=dima.kovol@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.