From: Paul Smith <paul@mad-scientist.net>
To: git@vger.kernel.org
Subject: git 2.9.2: is RUNTIME_PREFIX supposed to work?
Date: Mon, 26 Sep 2016 17:32:04 -0400 [thread overview]
Message-ID: <1474925524.4270.35.camel@mad-scientist.net> (raw)
Hi all. I'm trying to create a relocatable installation of Git 2.9.2,
so I can copy it anywhere and it continues to run without any problem.
This is on GNU/Linux systems, FWIW.
Looking through the code (for some other reason) I discovered the
RUNTIME_PREFIX setting which appears to attempt to set up the system
paths based on a prefix determined from the directory containing the
git command. That looks like exactly what I want.
If I set RUNTIME_PREFIX=YesPlease and gitexecdir=libexec/git-core on
the make invocation, it appears to do the right thing when I invoke
.../libexec/git-core/git, even if I move it around. Cool!
Except, when it doesn't. And when it doesn't is all the situations
where Git runs subcommands: for example, "git pull" which wants to
invoke fetch and merge-base commands.
When RUNTIME_PREFIX is defined, it's a requirement that the argv[0] for
the process be a fully-qualified pathname: if it's not, then git will
assert at exec_cmd.c:23 in system_path():
assert(argv0_path);
The argv0_path variable is set based on argv[0] passed in to main().
When I invoke top-level Git commands, that value is a fully-qualified
path just as you'd expect. However, when Git itself invokes
subcommands it does so in a weird way where argv[0] is the command it
wants to invoke, using the magical execv() facility that lets you
invoke a command while providing a different value as argv[0].
For example my core dump from the assert of the merge-base shows:
(gdb) p argv[0]
$2 = 0x7fffd70c338e "merge-base"
(gdb) p argv[1]
$3 = 0x7fffd70c3399 "--fork-point"
(gdb) p argv[2]
$4 = 0x7fffd70c33a6 "refs/remotes/origin/master"
(gdb) p argv[3]
$5 = 0x7fffd70c33c1 "master"
Looking at builtin/pull.c I see get_rebase_fork_point() calls
capture_command() with this Git command, which calls start_command(),
which calls execv_git_command(), which calls sane_execvp(), which
invokes "git" as the filename but with argv[0] as "merge-base":
sane_execvp("git", (char **)nargv.argv);
...calls sane_execvp():
if (!execvp(file, argv))
return 0; /* cannot happen ;-) */
This causes the assert.
So, my question is: is this a bug in RUNTIME_PREFIX support? Or is
RUNTIME_PREFIX no longer supported, or maybe not supported at all on
UNIX-type operating systems?
Cheers!
next reply other threads:[~2016-09-26 21:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-26 21:32 Paul Smith [this message]
2016-09-26 21:57 ` git 2.9.2: is RUNTIME_PREFIX supposed to work? Junio C Hamano
2016-09-27 13:18 ` Paul Smith
2016-09-27 15:34 ` Johannes Schindelin
2016-09-27 16:15 ` Junio C Hamano
2016-09-27 16:37 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474925524.4270.35.camel@mad-scientist.net \
--to=paul@mad-scientist.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).