1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-04-27 22:35:12 +02:00

Merge branch 'js/runtime-prefix'

* js/runtime-prefix:
  Avoid multiple PREFIX definitions
  git_setup_gettext: plug memory leak
  gettext: avoid initialization if the locale dir is not present
This commit is contained in:
Junio C Hamano 2018-05-08 15:59:34 +09:00
commit 71c848bb28
4 changed files with 17 additions and 9 deletions

View File

@ -2284,7 +2284,7 @@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTRA_CPPFLAGS = \
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
'-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
'-DBINDIR="$(bindir_relative_SQ)"' \
'-DPREFIX="$(prefix_SQ)"'
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \

View File

@ -48,7 +48,7 @@ static const char *system_prefix(void)
!(prefix = strip_path_suffix(executable_dirname, GIT_EXEC_PATH)) &&
!(prefix = strip_path_suffix(executable_dirname, BINDIR)) &&
!(prefix = strip_path_suffix(executable_dirname, "git"))) {
prefix = PREFIX;
prefix = FALLBACK_RUNTIME_PREFIX;
trace_printf("RUNTIME_PREFIX requested, "
"but prefix computation failed. "
"Using static fallback '%s'.\n", prefix);
@ -243,7 +243,7 @@ void git_resolve_executable_dir(const char *argv0)
*/
static const char *system_prefix(void)
{
return PREFIX;
return FALLBACK_RUNTIME_PREFIX;
}
/*

View File

@ -159,15 +159,23 @@ static void init_gettext_charset(const char *domain)
void git_setup_gettext(void)
{
const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
char *p = NULL;
if (!podir)
podir = system_path(GIT_LOCALE_PATH);
podir = p = system_path(GIT_LOCALE_PATH);
if (!is_directory(podir)) {
free(p);
return;
}
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 */

View File

@ -13,7 +13,7 @@
* the remote died unexpectedly. A flush() concludes the stream.
*/
#define PREFIX "remote: "
#define DISPLAY_PREFIX "remote: "
#define ANSI_SUFFIX "\033[K"
#define DUMB_SUFFIX " "
@ -49,7 +49,7 @@ int recv_sideband(const char *me, int in_stream, int out)
switch (band) {
case 3:
strbuf_addf(&outbuf, "%s%s%s", outbuf.len ? "\n" : "",
PREFIX, buf + 1);
DISPLAY_PREFIX, buf + 1);
retval = SIDEBAND_REMOTE_ERROR;
break;
case 2:
@ -67,7 +67,7 @@ int recv_sideband(const char *me, int in_stream, int out)
int linelen = brk - b;
if (!outbuf.len)
strbuf_addstr(&outbuf, PREFIX);
strbuf_addstr(&outbuf, DISPLAY_PREFIX);
if (linelen > 0) {
strbuf_addf(&outbuf, "%.*s%s%c",
linelen, b, suffix, *brk);
@ -81,8 +81,8 @@ int recv_sideband(const char *me, int in_stream, int out)
}
if (*b)
strbuf_addf(&outbuf, "%s%s",
outbuf.len ? "" : PREFIX, b);
strbuf_addf(&outbuf, "%s%s", outbuf.len ?
"" : DISPLAY_PREFIX, b);
break;
case 1:
write_or_die(out, buf + 1, len);