Re: [PATCH v6 3/3] exec_cmd: RUNTIME_PREFIX on some POSIX systems
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 19, 2018, 17:24 UTC
- Message-ID
- <xmqq7eq8vv09.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180319025046.58052-4-dnj@google.com>
Dan Jacques <dnj@google.com> writes:
Show 20 quoted lines
> Enable Git to resolve its own binary location using a variety of > OS-specific and generic methods, including: > > - procfs via "/proc/self/exe" (Linux) > - _NSGetExecutablePath (Darwin) > - KERN_PROC_PATHNAME sysctl on BSDs. > - argv0, if absolute (all, including Windows). > > This is used to enable RUNTIME_PREFIX support for non-Windows systems, > notably Linux and Darwin. When configured with RUNTIME_PREFIX, Git will > do a best-effort resolution of its executable path and automatically use > this as its "exec_path" for relative helper and data lookups, unless > explicitly overridden. > > Small incidental formatting cleanup of "exec_cmd.c". > > Signed-off-by: Dan Jacques <dnj@google.com> > Thanks-to: Robbie Iannucci <iannucci@google.com> > Thanks-to: Junio C Hamano <gitster@pobox.com> > ---
Look for these misspelled words:
sysetems
applicaton
authoratativeShow 18 quoted lines
> diff --git a/Makefile b/Makefile > index 101a98a78..df17a62a4 100644 > --- a/Makefile > +++ b/Makefile > @@ -418,6 +418,16 @@ all:: > # > # Define HAVE_BSD_SYSCTL if your platform has a BSD-compatible sysctl function. > # > +# Define HAVE_BSD_KERN_PROC_SYSCTL if your platform supports the KERN_PROC BSD > +# sysctl function. > +# > +# Define PROCFS_EXECUTABLE_PATH if your platform mounts a "procfs" filesystem > +# capable of resolving the path of the current executable. If defined, this > +# must be the canonical path for the "procfs" current executable path. > +# > +# Define HAVE_NS_GET_EXECUTABLE_PATH if your platform supports calling > +# _NSGetExecutablePath to retrieve the path of the running executable. > +#
Sounds sensible.
Show 32 quoted lines
> +/**
> + * Path to the current Git executable. Resolved on startup by
> + * 'git_resolve_executable_dir'.
> + */
> +static const char *executable_dirname;
>
> static const char *system_prefix(void)
> {
> static const char *prefix;
>
> - assert(argv0_path);
> - assert(is_absolute_path(argv0_path));
> + assert(executable_dirname);
> + assert(is_absolute_path(executable_dirname));
>
> 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 = strip_path_suffix(executable_dirname, GIT_EXEC_PATH)) &&
> + !(prefix = strip_path_suffix(executable_dirname, BINDIR)) &&
> + !(prefix = strip_path_suffix(executable_dirname, "git"))) {
> prefix = PREFIX;
> trace_printf("RUNTIME_PREFIX requested, "
> - "but prefix computation failed. "
> - "Using static fallback '%s'.\n", prefix);
> + "but prefix computation failed. "
> + "Using static fallback '%s'.\n",
> + prefix);
> }
> return prefix;
> }OK. An essentially no-op change but with the name better suited in the extended context---we used to only care about argv0 but that was an implementation detail of "where did our binary come from". Nice.