Skip to content

Commit 15edb00

Browse files
committed
gettext: handle GIT_TEXTDOMAINDIR relative to $(prefix)
On Windows, there is no single root directory. And what Git thinks is a root directory is not a root directory at all: everything is relative to the location where Git is installed. To handle this situation better, let's just allow for GIT_TEXTDOMAINDIR to be a path relative to the (runtime) prefix. To that end, we have to switch the order in which common-main handles argv0 and sets up gettext: in order to have access to the runtime prefix, we need it to be inferred from argv0 already. This patch also prepares for GIT_LOCALE_PATH to be relative to prefix, which is the even more important fix. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 599fd1d commit 15edb00

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

common-main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ int main(int argc, const char **argv)
3131
*/
3232
sanitize_stdfds();
3333

34-
git_setup_gettext();
35-
3634
git_extract_argv0_path(argv[0]);
3735

36+
git_setup_gettext();
37+
3838
restore_sigpipe_to_default();
3939

4040
return cmd_main(argc, argv);

gettext.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "gettext.h"
77
#include "strbuf.h"
88
#include "utf8.h"
9+
#include "cache.h"
10+
#include "exec_cmd.h"
911

1012
#ifndef NO_GETTEXT
1113
# include <locale.h>
@@ -160,14 +162,20 @@ static void init_gettext_charset(const char *domain)
160162
void git_setup_gettext(void)
161163
{
162164
const char *podir = getenv("GIT_TEXTDOMAINDIR");
165+
char *p = NULL;
163166

164167
if (!podir)
165168
podir = GIT_LOCALE_PATH;
169+
if (!is_absolute_path(podir))
170+
podir = p = system_path(podir);
171+
166172
bindtextdomain("git", podir);
167173
setlocale(LC_MESSAGES, "");
168174
setlocale(LC_TIME, "");
169175
init_gettext_charset("git");
170176
textdomain("git");
177+
178+
free(p);
171179
}
172180

173181
/* return the number of columns of string 's' in current locale */

0 commit comments

Comments
 (0)