Skip to content

configure: add --with-git flag - #365

Open
hakre wants to merge 1 commit into
php:masterfrom
hakre:patch-2
Open

hakre wants to merge 1 commit into
php:masterfrom
hakre:patch-2

Conversation

@hakre

@hakre hakre commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Add --with-git=auto|yes|no|PATH. Default is auto; no disables all Git usage; yes fails hard if Git is missing. A non-zero exit from git --version is treated as "not usable" and falls back to auto.

Previously, configure.php unconditionally invoked Git, which fails in environments that do not provide it by default. The exit status (127) was then tested for failure and the script stopped with the following diagnostic (shortened):

configure.php on PHP 8.5.13, libxml 2.9.14
...
sh: 1: git: not found
doc-base/temp clean up FAILED.

git_clean() only ever cleans temp/, which is committed via temp/.keep and is empty in fresh checkouts. The cleanup is therefore not required for reproducibility in Dockerfile ADD-based and similar builds, but kept for environments that do use Git (e.g. local working trees or manual clones).

The Git dependency is now explicit and optional, controlled entirely by --with-git.

To verify the behavior, I ran configure with and without a Git shim in PATH, covering all four modes plus the explicit-path cases:

Git in PATH Flag Detected as Result
no (default) no build proceeds
yes (default) yes, /usr/bin/git build proceeds
yes --without-git no build proceeds
yes --with-git yes, /usr/bin/git build proceeds
yes --with-git=git yes, /usr/bin/git build proceeds
yes --with-git= yes, /usr/bin/git build proceeds
yes --with-git=auto yes, /usr/bin/git build proceeds
no --with-git=auto no build proceeds
no --with-git — hard error: "Could not find the Git binary"
no --with-git=/dev/null — hard error: "Not an executable file: '/dev/null'"
no --with-git=/usr/bin/git — hard error: "No such file or directory: '/usr/bin/git'"
no --with-git=gotools/gitx — hard error: "No such file or directory: 'gotools/gitx'"

Add --with-git=auto|yes|no|PATH. Default is auto; no disables
all Git usage; yes fails hard if Git is missing. A non-zero
exit from `git --version` is treated as "not usable" and
falls back to auto.

Previously, configure.php unconditionally invoked Git, which
fails in environments that do not provide it by default. The
exit status (127) was then tested for failure and the script
stopped with the following diagnostic (shortened):

    configure.php on PHP 8.5.13, libxml 2.9.14
    ...
    sh: 1: git: not found
    doc-base/temp clean up FAILED.

git_clean() only ever cleans temp/, which is committed via
temp/.keep and is empty in fresh checkouts. The cleanup is
therefore not required for reproducibility in Dockerfile
ADD-based and similar builds, but kept for environments that
do use Git (e.g. local working trees or manual clones).

The Git dependency is now explicit and optional, controlled
entirely by --with-git.
@alfsb

alfsb commented Dec 1, 2026

Copy link
Copy Markdown
Member

Instead of adding an option that disables git on git_clean(), I would prefer making this function to generate a soft error / warning in case of failure.

The logic behind using git to remove files is to avoid calling some uncontrollable rm -rf on people's hard disks. If there are uses of configure.php that runs without git installed, in "single run scenarios", it's better to document that directly in code.

In git_clean(), first list all files of temp. If there is only a single dot file, then return. If not, git clean should run, and also should fail or, at least, should emit a warning about "missing git, manual build is not idempotent", before continuing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants