* [PATCH] Conflicting PREFIX usage
@ 2016-05-05 21:28 Philip Oakley
2016-05-05 21:28 ` [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions Philip Oakley
0 siblings, 1 reply; 7+ messages in thread
From: Philip Oakley @ 2016-05-05 21:28 UTC (permalink / raw)
To: GitList, Self; +Cc: Junio C Hamano, Johannes Schindelin, git-for-windows
While trying to resurrect the MSVC/Visual Studio capability for Git
for Windows I noticed this little nuance.
The PREFIX in Windows was introduced in 35fb0e8 (Compute prefix at runtime
if RUNTIME_PREFIX is set, 2009-01-18) and in sideband.c at ebe8fa7
(fix display overlap between remote and local progress, 2007-11-04) though
clash has not been noticed before.
The attached patch simply gives the two PREFIXs more purposeful names of
EXEC_PREFIX and DISPLAY_PREFIX.
Philip Oakley (1):
exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions
Makefile | 2 +-
exec_cmd.c | 4 ++--
sideband.c | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
--
2.8.1.windows.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions
2016-05-05 21:28 [PATCH] Conflicting PREFIX usage Philip Oakley
@ 2016-05-05 21:28 ` Philip Oakley
2016-05-05 22:02 ` Junio C Hamano
2016-05-06 6:18 ` [git-for-windows] " Johannes Sixt
0 siblings, 2 replies; 7+ messages in thread
From: Philip Oakley @ 2016-05-05 21:28 UTC (permalink / raw)
To: GitList, Self; +Cc: Junio C Hamano, Johannes Schindelin, git-for-windows
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions
2016-05-05 21:28 ` [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions Philip Oakley
@ 2016-05-05 22:02 ` Junio C Hamano
2016-05-06 7:23 ` Philip Oakley
2016-05-06 6:18 ` [git-for-windows] " Johannes Sixt
1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2016-05-05 22:02 UTC (permalink / raw)
To: Philip Oakley; +Cc: GitList, Johannes Schindelin, git-for-windows
Philip Oakley <philipoakley@iee.org> writes:
> 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
Good eyes.
>
> 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)"'
I am not entirely happy with this name as the name can be easily
confused with GIT_EXEC_PATH.
This is a fallback used under RUNTIME_PREFIX option, if I am reading
the code correctly, so the name should hint the linkage between the
"runtime prefix" mechanism and this variable.
Perhaps RUNTIME_PREFIX_FALLBACK? Used at only two places, that
should not be an overlong name.
DISPLAY_PREFIX is OK, as it is an entirely a local thing to
sideband.c, but with the externally visible PREFIX fixed to be a
more appropriate name that hints its relation with the "runtime
prefix" mechanism, it may be better not to even touch it.
> 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);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [git-for-windows] [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions
2016-05-05 21:28 ` [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions Philip Oakley
2016-05-05 22:02 ` Junio C Hamano
@ 2016-05-06 6:18 ` Johannes Sixt
2016-05-06 7:31 ` Philip Oakley
1 sibling, 1 reply; 7+ messages in thread
From: Johannes Sixt @ 2016-05-06 6:18 UTC (permalink / raw)
To: Philip Oakley
Cc: GitList, Junio C Hamano, Johannes Schindelin, git-for-windows
Am 05.05.2016 um 23:28 schrieb Philip Oakley:
> 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
You should describe the circumstances better under which you notice a
conflict, because there is no conflict when Git is built with the
Makefile and 'make':
> 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)"'
Notice that PREFIX is set only for a small subset of .c files.
sideband.c is not among them.
-- Hannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions
2016-05-05 22:02 ` Junio C Hamano
@ 2016-05-06 7:23 ` Philip Oakley
2016-05-06 16:55 ` Junio C Hamano
0 siblings, 1 reply; 7+ messages in thread
From: Philip Oakley @ 2016-05-06 7:23 UTC (permalink / raw)
To: Junio C Hamano; +Cc: GitList, Johannes Schindelin, git-for-windows
From: "Junio C Hamano" <gitster@pobox.com>
> Philip Oakley <philipoakley@iee.org> writes:
>
>> 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
>
> Good eyes.
>
>>
>> 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)"'
>
> I am not entirely happy with this name as the name can be easily
> confused with GIT_EXEC_PATH.
>
> This is a fallback used under RUNTIME_PREFIX option, if I am reading
> the code correctly, so the name should hint the linkage between the
> "runtime prefix" mechanism and this variable.
>
> Perhaps RUNTIME_PREFIX_FALLBACK? Used at only two places, that
> should not be an overlong name.
Perhaps EXEC_CMD_PREFIX, for that is what it is? And it's got a 2-way
difference from the GIT_EXEC_PATH. I wasn't seeing it as a fallback, rather
just a different way the OS uses to get to the path. If anything
RUNTIME_PREFIX feels a bit long for a flag.
>
> DISPLAY_PREFIX is OK, as it is an entirely a local thing to
> sideband.c, but with the externally visible PREFIX fixed to be a
> more appropriate name that hints its relation with the "runtime
> prefix" mechanism, it may be better not to even touch it.
>
>> 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);
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [git-for-windows] [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions
2016-05-06 6:18 ` [git-for-windows] " Johannes Sixt
@ 2016-05-06 7:31 ` Philip Oakley
0 siblings, 0 replies; 7+ messages in thread
From: Philip Oakley @ 2016-05-06 7:31 UTC (permalink / raw)
To: Johannes Sixt
Cc: GitList, Junio C Hamano, Johannes Schindelin, git-for-windows
From: "Johannes Sixt" <j6t@kdbg.org>
> Am 05.05.2016 um 23:28 schrieb Philip Oakley:
>> 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
>
> You should describe the circumstances better under which you notice a
> conflict, because there is no conflict when Git is built with the Makefile
> and 'make':
I haven't dug deep into the G4W make results so I can't say either way
regarding the make on G4W, but it does show when creating the Git.sln
project via the contrib process. It is specific to the Windows OS and how it
generates the path to the exe (You will know far more than me).
see below regarding commit message
>
>> 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)"'
>
> Notice that PREFIX is set only for a small subset of .c files. sideband.c
> is not among them.
The issue is in the libgit sub-project, where both reside side by side, and
when sideband.c is being compiled, the PREFIX has also been declared on the
command line, thus giving the unexpected conflict.
I'll bring more of the explanation into the commit message.
--
Philip
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions
2016-05-06 7:23 ` Philip Oakley
@ 2016-05-06 16:55 ` Junio C Hamano
0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2016-05-06 16:55 UTC (permalink / raw)
To: Philip Oakley; +Cc: GitList, Johannes Schindelin
Dropped "git-for-windows" <git-for-windows@googlegroups.com> from
the Cc: list, as I seem to be getting bounces from it due to its
moderation policy.
"Philip Oakley" <philipoakley@iee.org> writes:
> Perhaps EXEC_CMD_PREFIX, for that is what it is?
That name is doubly wrong, I have to say.
This is used only after RUNTIME_PREFIX heuristics to learn the
binary location from argv[0] fails, or the result of it does not
have expected suffix string (i.e. GIT_EXEC_PATH . BINDIR . "git").
The code even says this:
if (!prefix &&
!(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;
trace_printf("RUNTIME_PREFIX requested, "
"but prefix computation failed. "
"Using static fallback '%s'.\n", prefix);
}
Notice "static fallback" there?
I have a very strong preference for the name to reflect that fact.
I.e. send a signal to those who do not use RUNTIME_PREFIX
configuration that they do not have to care.
Also "EXEC" is wrong, too. The way the 'prefix' variable we see
above is used is that system_path() takes a directory path to
various installed component of the Git package, e.g. GIT_MAN_PATH
is the location for manual pages, as its "path" parameter, and
then
strbuf_addf(&d, "%s/%s", prefix, path);
is used to formulate the absolute path for it. A name with "EXEC"
in it would incorrectly hint that it points at a rough equivalent to
/usr/local/bin/ or /usr/local/libexec/git/, but PREFIX corresponds
more to /usr/local/.
Even if J6t's point about these two separate PREFIXes should never
exist at the same time is correct, I think it is a good change to
use a more explicit name for this variable that is used to
communicate between Makefile and the *.c source.
As to your "RUNTIME_PREFIX_FALLBACK is very long" objection, I do
not care ;-) More seriously, this is not something typed very often.
It appears only twice in this codepath and having clear names to
tell readers what it is about is much more important.
I do agree the most logical name, after understanding all of the
above, which is RUNTIME_PREFIX_STATIC_FALLBACK, may be a bit too
long, though.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-05-06 16:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-05 21:28 [PATCH] Conflicting PREFIX usage Philip Oakley
2016-05-05 21:28 ` [PATCH] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions Philip Oakley
2016-05-05 22:02 ` Junio C Hamano
2016-05-06 7:23 ` Philip Oakley
2016-05-06 16:55 ` Junio C Hamano
2016-05-06 6:18 ` [git-for-windows] " Johannes Sixt
2016-05-06 7:31 ` Philip Oakley
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).