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

Re: [PATCH v7 0/3] RUNTIME_PREFIX relocatable Git

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 26, 2018, 21:16 UTC
Message-ID
<nycvar.QRO.7.76.6.1803262305010.77@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz>
In-Reply-To
<CAD1RUU-oUXx+mGUe6QuTawLhLz1nGFZiOWnF7=DVA1uf455zfw@mail.gmail.com>
Hi,
On Mon, 26 Mar 2018, Daniel Jacques wrote:
Show 12 quoted lines
> On Mon, Mar 26, 2018 at 2:01 AM Junio C Hamano <gitster@pobox.com> wrote:
> 
> > I wonder if the relocatable Git would allow a simpler arrangement to
> > test without installing.
> 
> > I am asking merely out of curiosity, not suggesting to make a trial
> > install somewhere in the build area and run the built Git normally
> > without GIT_EXEC_PATH trick.
> 
> RUNTIME_PREFIX resolves paths relative to the runtime path of the Git
> binary. These path expectations are constructed around installation
> directories, so I'd expect that installation is a prerequisite of testing.
Indeed. This is the relevant part of the code:
        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 = FALLBACK_RUNTIME_PREFIX;
                trace_printf("RUNTIME_PREFIX requested, "
                                "but prefix computation failed.  "
                                "Using static fallback '%s'.\n", prefix);
        }

Note how the argv0_path (which is the absolute path of the directory *containing* the `git` executable) is tested for several suffixes, i.e. trailing directories, namely

	libexec/git-core
	bin
	git

That means that you will have to have your `git` executable built in a worktree whose absolute path ends in one of these.

While writing this reply, I was wondering why "git" is included in this list. You know, I can see libexec/git-core and bin because that is where the `git` executable is installed to (or hard-linked to). But "git"?

Turns out that I am the responsible person for that (024aa7d8d51 (system_path(): simplify using strip_path_suffix(), and add suffix "git", 2009-02-19)), having assumed back then that everybody who uses the RUNTIME_PREFIX feature and works on Git does so in /git/. Which is of course no longer true in general. For example, I myself got bitten by this when developing some patches on top of Dan's patch series in a *linked worktree* of the name "runtime-prefix". Oh well.

But the short answer is: no, you cannot rely on the RUNTIME_PREFIX feature for running Git's own test suite. The GIT_EXEC_PATH method to force Git's test suite to use the compiled executables is still required.

Even if it is fragile: if git-FOO exists in <prefix>/bin/ and some test relies on the FOO subcommand but we removed it from the source code to test whether it is needed, the test suite would pass just fine because it finds git-FOO in the PATH.

*sigh* seems that I cannot write short answers.

Ciao, Dscho

Previous: Daniel JacquesNext: Johannes Schindelin
Message 11 of 20 in “RUNTIME_PREFIX relocatable Git”
  1. 0/3 RUNTIME_PREFIX relocatable GitDan Jacques, Mar 25, 2018
  2. 1/3 Makefile: generate Perl header from template fileDan Jacques, Mar 25, 2018
  3. 2/3 Makefile: add Perl runtime prefix supportDan Jacques, Mar 25, 2018
  4. 3/3 exec_cmd: RUNTIME_PREFIX on some POSIX systemsDan Jacques, Mar 25, 2018
  5. Ævar Arnfjörð BjarmasonMar 25, 2018
  6. Daniel JacquesMar 26, 2018
  7. Ævar Arnfjörð BjarmasonMar 26, 2018
  8. Daniel JacquesMar 26, 2018
  9. Junio C HamanoMar 26, 2018
  10. Daniel JacquesMar 26, 2018
  11. Johannes SchindelinMar 26, 2018
  12. 0/2 Add Windows support to the new RUNTIME_PREFIX designJohannes Schindelin, Mar 26, 2018
  13. Daniel JacquesMar 27, 2018
  14. Johannes SchindelinMar 27, 2018
  15. Daniel JacquesMar 27, 2018
  16. Johannes SchindelinMar 27, 2018
  17. Junio C HamanoMar 28, 2018
  18. Johannes SchindelinMar 29, 2018
  19. 1/2 exec_cmd: provide a new-style RUNTIME_PREFIX helper for WindowsJohannes Schindelin, Mar 26, 2018
  20. 2/2 mingw/msvc: use the new-style RUNTIME_PREFIX helperJohannes Schindelin, Mar 26, 2018

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.