Skip to content

Makefile: Fix GIT_EXTRA_VERSION being set when overriding GIT_PATCHES

Patrick Steinhardt requested to merge pks-git-extra-version-undefined into master

When we're not applying any custom patches, then we typically wouldn't want to define a custom GitLab patch level because otherwise it may easily mislead anybody to think that custom patches have indeed been applied. This isn't currently working as expected though: if one builds git with make git GIT_PATCHES=, then we do not apply any patches but still have the GIT_EXTRA_VERSION defined.

The root cause of this is a misunderstanding of the ifndef directive: the expectation is that this will only evaluate to true if the value has not been previously defined. But what it really does is to return true in case the value is either undefined or evaluates to the empty string. As a result, we'd set up GIT_PATCHES and GIT_EXTRA_VERSION even when the caller has explicitly set GIT_PATCHES to be the empty string. While GIT_PATCHES won't be appended to because values which have been defined by the user won't be overridden by default, GIT_EXTRA_VERSION will be set up. So this construct only worked by chance.

Fix this bug by explicitly testing whether GIT_PATCHES is undefined via the $(origin ...) function. While at it, we also fix all the other occurrences where this may eventually cause unintended behaviour.

Merge request reports

Loading