diff --git a/Makefile b/Makefile index d7c97870c4d923..a6d9f2854c33a7 100644 --- a/Makefile +++ b/Makefile @@ -445,6 +445,7 @@ lib = lib # DESTDIR = pathsep = : +localedir_relative = $(patsubst $(prefix)/%,%,$(localedir)) mandir_relative = $(patsubst $(prefix)/%,%,$(mandir)) infodir_relative = $(patsubst $(prefix)/%,%,$(infodir)) htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir)) @@ -1603,6 +1604,7 @@ bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) mandir_relative_SQ = $(subst ','\'',$(mandir_relative)) infodir_relative_SQ = $(subst ','\'',$(infodir_relative)) localedir_SQ = $(subst ','\'',$(localedir)) +localedir_relative_SQ = $(subst ','\'',$(localedir_relative)) gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) template_dir_SQ = $(subst ','\'',$(template_dir)) htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative)) @@ -2039,7 +2041,7 @@ attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \ gettext.sp gettext.s gettext.o: GIT-PREFIX gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \ - -DGIT_LOCALE_PATH='"$(localedir_SQ)"' + -DGIT_LOCALE_PATH='"$(localedir_relative_SQ)"' http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp: SPARSE_FLAGS += \ -DCURL_DISABLE_TYPECHECK diff --git a/common-main.c b/common-main.c index c654f95551c33d..548da64ab62c95 100644 --- a/common-main.c +++ b/common-main.c @@ -31,10 +31,10 @@ int main(int argc, const char **argv) */ sanitize_stdfds(); - git_setup_gettext(); - git_extract_argv0_path(argv[0]); + git_setup_gettext(); + restore_sigpipe_to_default(); return cmd_main(argc, argv); diff --git a/gettext.c b/gettext.c index 7d9e2c27eff9f6..0a974f9cd1580c 100644 --- a/gettext.c +++ b/gettext.c @@ -6,6 +6,8 @@ #include "gettext.h" #include "strbuf.h" #include "utf8.h" +#include "cache.h" +#include "exec_cmd.h" #ifndef NO_GETTEXT # include @@ -160,14 +162,22 @@ static void init_gettext_charset(const char *domain) void git_setup_gettext(void) { const char *podir = getenv("GIT_TEXTDOMAINDIR"); + char *p = NULL; if (!podir) podir = GIT_LOCALE_PATH; - bindtextdomain("git", podir); - setlocale(LC_MESSAGES, ""); - setlocale(LC_TIME, ""); - init_gettext_charset("git"); - textdomain("git"); + if (!is_absolute_path(podir)) + podir = p = system_path(podir); + + if (is_directory(podir)) { + bindtextdomain("git", podir); + setlocale(LC_MESSAGES, ""); + setlocale(LC_TIME, ""); + init_gettext_charset("git"); + textdomain("git"); + } + + free(p); } /* return the number of columns of string 's' in current locale */