Avoid multiple PREFIX definitions

The short and sweet PREFIX can be confused when used in many places.

Rename both usages to better describe their purpose. EXEC_CMD_PREFIX is
used in full to disambiguate it from the nearby GIT_EXEC_PATH.

The PREFIX in sideband.c, while nominally independant of the exec_cmd
PREFIX, does reside within libgit[1], so the definitions would clash
when taken together with a PREFIX given on the command line for use by
exec_cmd.c.

Noticed when compiling Git for Windows using MSVC/Visual Studio [1] which
reports the conflict beteeen the command line definition and the
definition in sideband.c within the libgit project.

[1] the libgit functions are brought into a single sub-project
within the Visual Studio construction script provided in contrib,
and hence uses a single command for both exec_cmd.c and sideband.c.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Philip Oakley 2018-04-21 13:18:42 +02:00 committed by Junio C Hamano
parent 0210231b08
commit 4d5b4c2475
3 changed files with 8 additions and 8 deletions

View File

@ -2261,7 +2261,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \ '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
'-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \ '-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
'-DBINDIR="$(bindir_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: GIT-PREFIX
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \ 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, GIT_EXEC_PATH)) &&
!(prefix = strip_path_suffix(executable_dirname, BINDIR)) && !(prefix = strip_path_suffix(executable_dirname, BINDIR)) &&
!(prefix = strip_path_suffix(executable_dirname, "git"))) { !(prefix = strip_path_suffix(executable_dirname, "git"))) {
prefix = PREFIX; prefix = FALLBACK_RUNTIME_PREFIX;
trace_printf("RUNTIME_PREFIX requested, " trace_printf("RUNTIME_PREFIX requested, "
"but prefix computation failed. " "but prefix computation failed. "
"Using static fallback '%s'.\n", prefix); "Using static fallback '%s'.\n", prefix);
@ -243,7 +243,7 @@ void git_resolve_executable_dir(const char *argv0)
*/ */
static const char *system_prefix(void) static const char *system_prefix(void)
{ {
return PREFIX; return FALLBACK_RUNTIME_PREFIX;
} }
/* /*

View File

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