Skip to main content

Module git_program

Module git_program 

Source
Expand description

Which Git program to execute. Compiled into the host and, by path, into the independently built Axel memory service.

On macOS /usr/bin/git is Apple’s xcrun shim. Without the Command Line Tools, executing it opens the “install developer tools” dialog, and GIT_TERMINAL_PROMPT=0 does not prevent that. So on macOS Synaps never runs the shim: it runs a Git by absolute path, or treats Git as unavailable. Every other platform runs plain git from PATH, as before.

On macOS the host and the service deliberately follow different rules. Do not unify them:

  • The host (git_program) runs the Git the user’s shell runs: the first PATH directory with a git, so Homebrew, Nix and MacPorts Git keep working. Where PATH reaches the shim it runs the developer Git the shim would have run (so a PATH with /usr/bin first still gets Apple’s Git), or skips the shim when there is no developer Git. With no Git on PATH at all it falls back to the developer Git.
  • The Axel service (developer_git) never consults PATH. The host spawns it with an empty environment (env_clear: no PATH, no DEVELOPER_DIR), so nothing the host inherits picks the program the verifier runs. It runs the developer Git the shim would choose in an empty environment, as xcrun did for it before: the xcode-select choice, then Xcode, then the Command Line Tools.

So the two can run different Gits (say Homebrew’s and Apple’s). Both only run read-only rev-parse (Git 2.31 or newer), whose paths do not depend on the Git build. A service Git that cannot read the repository (too old for its format, say) makes the service fail closed with no scope, never yield a different identity.

Structs§

GitUnavailable
macOS has no Git: none on PATH and no developer Git (Apple’s Command Line Tools are not installed).

Functions§

developer_git
Plain git, found on PATH, exactly as before (only macOS resolves).
git_program
Plain git, found on PATH, exactly as before (only macOS resolves).
is_real_git
A Git that may be run: following symlinks, an executable regular file that is not the /usr/bin/git shim.
is_shim
git is, or links to, the /usr/bin/git shim.
resolve_developer_git
The macOS developer Git. Pure (the caller supplies DEVELOPER_DIR, the target of /var/db/xcode_select_link and the file test), so it builds and is tested on every platform. Candidate directories, in order:
resolve_path_git
The macOS host Git. Pure (the caller supplies PATH, the file tests and the developer Git), so it builds and is tested on every platform.