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

Re: [PATCH] exec_cmd: RUNTIME_PREFIX on OpenBSD systems

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 17, 2026, 13:45 UTC
Message-ID
<xmqqy0d0t2j9.fsf@gitster.g>
In-Reply-To
<aqthQ3u4eW1wHCn7@humpty.home.comstyle.com>
Brad Smith <brad@comstyle.com> writes:
> Enable Git to resolve its own binary location using getexecpath().

That may not be incorrect information per-se, but lacks critical bits. Natural initial questions that come to my mind are...

    Why would one want to use getexecpath() over whatever OpenBSD
    ports of Git have been using happily?  Is the old way being
    removed?  Is the new way being more accurate?  In what
    situations does the difference matter?  Is everybody on OpenBSD
    able to use this new function?  Do only certain, and/or
    presumably later, verions of OpenBSD have it?  How widely is it
    available?  How long has it been available?

Your proposed commit log messages do not answer any of these questions, but it should. The title can also use a bit of tweak to identify which versions of OpenBSD this patch is relevant.

Show 88 quoted lines
> Signed-off-by: Brad Smith <brad@comstyle.com>
> ---
>  Makefile         |  7 +++++++
>  config.mak.uname |  3 +++
>  exec-cmd.c       | 24 ++++++++++++++++++++++++
>  3 files changed, 34 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index d4b775953d..9e3d37b5b4 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -378,6 +378,9 @@ include shared.mak
>  # Perl scripts to use a modified entry point header allowing them to resolve
>  # support files at runtime.
>  #
> +# When using RUNTIME_PREFIX, define HAVE_GETEXECPATH if your platform supports
> +# the getexecpath() function.
> +#
>  # When using RUNTIME_PREFIX, define HAVE_BSD_KERN_PROC_SYSCTL if your platform
>  # supports the KERN_PROC BSD sysctl function.
>  #
> @@ -2356,6 +2359,10 @@ endif
>  
>  ifdef RUNTIME_PREFIX
>  
> +        ifdef HAVE_GETEXECPATH
> +		BASIC_CFLAGS += -DHAVE_GETEXECPATH
> +        endif
> +
>          ifdef HAVE_BSD_KERN_PROC_SYSCTL
>  		BASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL
>          endif
> diff --git a/config.mak.uname b/config.mak.uname
> index e28870434d..270aff1772 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -343,6 +343,9 @@ ifeq ($(uname_S),OpenBSD)
>  	CSPRNG_METHOD = arc4random
>  	FREAD_READS_DIRECTORIES = UnfortunatelyYes
>  	FILENO_IS_A_MACRO = UnfortunatelyYes
> +	ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 8 && echo 1),1)
> +		HAVE_GETEXECPATH = YesPlease
> +	endif
>  endif
>  ifeq ($(uname_S),MirBSD)
>  	NO_STRCASESTR = YesPlease
> diff --git a/exec-cmd.c b/exec-cmd.c
> index 507e67d528..5251da4229 100644
> --- a/exec-cmd.c
> +++ b/exec-cmd.c
> @@ -129,6 +129,26 @@ static int git_get_exec_path_bsd_sysctl(struct strbuf *buf)
>  }
>  #endif /* HAVE_BSD_KERN_PROC_SYSCTL */
>  
> +#ifdef HAVE_GETEXECPATH
> +/*
> + * Resolves the executable path using getexecpath(3).
> + *
> + * Returns 0 on success, -1 on failure.
> + */
> +static int git_get_exec_path_getexecpath(struct strbuf *buf)
> +{
> +	char path[PATH_MAX];
> +	if (getexecpath(path, sizeof(path)) == 0) {
> +		trace_printf(
> +			"trace: resolved executable path from getexecpath: %s\n",
> +			path);
> +		strbuf_addstr(buf, path);
> +		return 0;
> +	}
> +	return -1;
> +}
> +#endif /* HAVE_GETEXECPATH */
> +
>  #ifdef HAVE_NS_GET_EXECUTABLE_PATH
>  /*
>   * Resolves the executable path by querying Darwin application stack.
> @@ -209,6 +229,10 @@ static int git_get_exec_path(struct strbuf *buf, const char *argv0)
>  	 * after the first successful method.
>  	 */
>  	if (
> +#ifdef HAVE_GETEXECPATH
> +		git_get_exec_path_getexecpath(buf) &&
> +#endif /* HAVE_GETEXECPATH */
> +
>  #ifdef HAVE_BSD_KERN_PROC_SYSCTL
>  		git_get_exec_path_bsd_sysctl(buf) &&
>  #endif /* HAVE_BSD_KERN_PROC_SYSCTL */
Previous: Brad SmithNext: Brad Smith
Message 2 of 4 in “exec_cmd: RUNTIME_PREFIX on OpenBSD systems”
  1. exec_cmd: RUNTIME_PREFIX on OpenBSD systemsBrad Smith, Sep 17, 2026
  2. Junio C HamanoSep 17, 2026
  3. Brad SmithSep 21, 2026
  4. Junio C HamanoSep 21, 2026

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.