Skip to content

Commit 4d5b4c2

Browse files
Philip Oakleygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0210231 commit 4d5b4c2

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
22612261
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
22622262
'-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
22632263
'-DBINDIR="$(bindir_relative_SQ)"' \
2264-
'-DPREFIX="$(prefix_SQ)"'
2264+
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
22652265

22662266
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
22672267
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \

exec_cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static const char *system_prefix(void)
4848
!(prefix = strip_path_suffix(executable_dirname, GIT_EXEC_PATH)) &&
4949
!(prefix = strip_path_suffix(executable_dirname, BINDIR)) &&
5050
!(prefix = strip_path_suffix(executable_dirname, "git"))) {
51-
prefix = PREFIX;
51+
prefix = FALLBACK_RUNTIME_PREFIX;
5252
trace_printf("RUNTIME_PREFIX requested, "
5353
"but prefix computation failed. "
5454
"Using static fallback '%s'.\n", prefix);
@@ -243,7 +243,7 @@ void git_resolve_executable_dir(const char *argv0)
243243
*/
244244
static const char *system_prefix(void)
245245
{
246-
return PREFIX;
246+
return FALLBACK_RUNTIME_PREFIX;
247247
}
248248

249249
/*

sideband.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* the remote died unexpectedly. A flush() concludes the stream.
1414
*/
1515

16-
#define PREFIX "remote: "
16+
#define DISPLAY_PREFIX "remote: "
1717

1818
#define ANSI_SUFFIX "\033[K"
1919
#define DUMB_SUFFIX " "
@@ -49,7 +49,7 @@ int recv_sideband(const char *me, int in_stream, int out)
4949
switch (band) {
5050
case 3:
5151
strbuf_addf(&outbuf, "%s%s%s", outbuf.len ? "\n" : "",
52-
PREFIX, buf + 1);
52+
DISPLAY_PREFIX, buf + 1);
5353
retval = SIDEBAND_REMOTE_ERROR;
5454
break;
5555
case 2:
@@ -67,7 +67,7 @@ int recv_sideband(const char *me, int in_stream, int out)
6767
int linelen = brk - b;
6868

6969
if (!outbuf.len)
70-
strbuf_addstr(&outbuf, PREFIX);
70+
strbuf_addstr(&outbuf, DISPLAY_PREFIX);
7171
if (linelen > 0) {
7272
strbuf_addf(&outbuf, "%.*s%s%c",
7373
linelen, b, suffix, *brk);
@@ -81,8 +81,8 @@ int recv_sideband(const char *me, int in_stream, int out)
8181
}
8282

8383
if (*b)
84-
strbuf_addf(&outbuf, "%s%s",
85-
outbuf.len ? "" : PREFIX, b);
84+
strbuf_addf(&outbuf, "%s%s", outbuf.len ?
85+
"" : DISPLAY_PREFIX, b);
8686
break;
8787
case 1:
8888
write_or_die(out, buf + 1, len);

0 commit comments

Comments
 (0)