git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions

From
Philip Oakley <philipoakley@iee.org>
Date
May 5, 2016, 21:28 UTC
Message-ID
<1462483733-3496-2-git-send-email-philipoakley@iee.org>
In-Reply-To
<1462483733-3496-1-git-send-email-philipoakley@iee.org>
The short and sweet PREFIX can be confused when used in many places.
Rename both usages to better describe their purpose.

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

Signed-off-by: Philip Oakley <philipoakley@iee.org>
---
 Makefile   | 2 +-
 exec_cmd.c | 4 ++--
 sideband.c | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index 33b0f76..bcdd3ec 100644
--- a/Makefile
+++ b/Makefile
@@ -1973,7 +1973,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
 exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
 	'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
 	'-DBINDIR="$(bindir_relative_SQ)"' \
-	'-DPREFIX="$(prefix_SQ)"'
+	'-DEXEC_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 9d5703a..2a79781 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -12,7 +12,7 @@ char *system_path(const char *path)
 #ifdef RUNTIME_PREFIX
 	static const char *prefix;
 #else
-	static const char *prefix = PREFIX;
+	static const char *prefix = EXEC_PREFIX;
 #endif
 	struct strbuf d = STRBUF_INIT;
 
@@ -27,7 +27,7 @@ char *system_path(const char *path)
 	    !(prefix = strip_path_suffix(argv0_path, GIT_EXEC_PATH)) &&
 	    !(prefix = strip_path_suffix(argv0_path, BINDIR)) &&
 	    !(prefix = strip_path_suffix(argv0_path, "git"))) {
-		prefix = PREFIX;
+		prefix = EXEC_PREFIX;
 		trace_printf("RUNTIME_PREFIX requested, "
 				"but prefix computation failed.  "
 				"Using static fallback '%s'.\n", prefix);
diff --git a/sideband.c b/sideband.c
index fde8adc..d448ba7 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 "        "
@@ -22,13 +22,13 @@
 
 int recv_sideband(const char *me, int in_stream, int out)
 {
-	unsigned pf = strlen(PREFIX);
+	unsigned pf = strlen(DISPLAY_PREFIX);
 	unsigned sf;
 	char buf[LARGE_PACKET_MAX + 2*FIX_SIZE];
 	char *suffix, *term;
 	int skip_pf = 0;
 
-	memcpy(buf, PREFIX, pf);
+	memcpy(buf, DISPLAY_PREFIX, pf);
 	term = getenv("TERM");
 	if (isatty(2) && term && strcmp(term, "dumb"))
 		suffix = ANSI_SUFFIX;
-- 
2.8.1.windows.1
Previous: Philip OakleyNext: Junio C Hamano
Message 2 of 7 in “Conflicting PREFIX usage”
  1. Conflicting PREFIX usagePhilip Oakley, May 5, 2016
  2. exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitionsPhilip Oakley, May 5, 2016
  3. Junio C HamanoMay 5, 2016
  4. Philip OakleyMay 6, 2016
  5. Junio C HamanoMay 6, 2016
  6. Johannes SixtMay 6, 2016
  7. Philip OakleyMay 6, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.