git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] refactor of git_setup_gettext method

From
DGDima Kov via GitGitGadget <gitgitgadget@gmail.com>
Date
May 30, 2021, 21:42 UTC
Message-ID
<pull.964.git.1622410962551.gitgitgadget@gmail.com>
From: Dima Kov <dima.kovol@gmail.com>

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>
---
    refactor of git_setup_gettext method
    
    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
    
    Hi. My first PR fot Git repository. I went over the code and saw that
    maybe this part can be more clearer. Thanks.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-964%2Fdimakov%2Ffree_opt-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-964/dimakov/free_opt-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/964
 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
-- 
gitgitgadget
Next: Eric Sunshine
Message 1 of 4 in “refactor of git_setup_gettext method”
  1. refactor of git_setup_gettext methodDima Kov via GitGitGadget, May 30, 2021
  2. Eric SunshineMay 30, 2021
  3. Junio C HamanoMay 31, 2021
  4. Bagas SanjayaMay 31, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.