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
diff --git a/Makefile b/Makefile
index 4541788..ad880d1 100644
--- a/Makefile
+++ b/Makefile
@@ -2284,7 +2284,7 @@
 	'-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 = \
diff --git a/exec-cmd.c b/exec-cmd.c
index 3b0a039..02d31ee 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -48,7 +48,7 @@
 	    !(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 @@
  */
 static const char *system_prefix(void)
 {
-	return PREFIX;
+	return FALLBACK_RUNTIME_PREFIX;
 }
 
 /*
diff --git a/gettext.c b/gettext.c
index baba283..7272771 100644
--- a/gettext.c
+++ b/gettext.c
@@ -159,15 +159,23 @@
 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 */
diff --git a/sideband.c b/sideband.c
index 6d7f943..325bf0e 100644
--- a/sideband.c
+++ b/sideband.c
@@ -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 @@
 		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 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 @@
 			}
 
 			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);