Dan Jacques <[email protected]> writes:

> 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 <[email protected]>
> Thanks-to: Robbie Iannucci <[email protected]>
> Thanks-to: Junio C Hamano <[email protected]>
> ---

Look for these misspelled words:

    sysetems
    applicaton
    authoratative

> 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.

> +/**
> + * 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.

Reply via email to