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

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

From
Junio C Hamano <gitster@pobox.com>
Date
May 6, 2016, 16:55 UTC
Message-ID
<xmqqd1oz5dow.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1C7D96C1B53D45CCAA8658C9DBB1AAB5@PhilipOakley>

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.

Previous: Philip OakleyNext: Johannes Sixt
Message 5 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.