Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-07 09:10:46 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-07 09:24:09 +0300
commit88df87a9ce8b0ebb13b25a4a4462c918d23eecbb (patch)
tree1d1e59e21a40bdef69dabc56a00c5a6f457adb57 /Makefile
parent612a67c82636b4057347de587b0f8ce230df616f (diff)
Makefile: Fix GIT_EXTRA_VERSION being set when overriding GIT_PATCHES
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.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile14
1 files changed, 7 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 38ffbce2c..db5f4b46d 100644
--- a/Makefile
+++ b/Makefile
@@ -86,7 +86,7 @@ LIBGIT2_VERSION ?= v1.1.0
# Support both vX.Y.Z and X.Y.Z version patterns, since callers across
# GitLab use both.
-ifndef GIT_VERSION
+ifeq ($(origin GIT_VERSION),undefined)
GIT_VERSION := v2.33.0
else
GIT_VERSION := $(shell echo ${GIT_VERSION} | awk '/^[0-9]\.[0-9]+\.[0-9]+$$/ { printf "v" } { print $$1 }')
@@ -110,7 +110,7 @@ ifeq (${Q},@)
GIT_QUIET = --quiet
endif
-ifndef GIT_PATCHES
+ifeq ($(origin GIT_PATCHES),undefined)
# Before adding custom patches, please read doc/PROCESS.md#Patching-git
# first to make sure your patches meet our acceptance criteria. Patches
# must be put into `_support/git-patches`.
@@ -127,10 +127,10 @@ ifndef GIT_PATCHES
# incremented whenever a new patch is added above. When no patches exist,
# then this should be undefined. Otherwise, it must be set to at least
# `gl1` given that `0` is the "default" GitLab patch level.
- GIT_EXTRA_VERSION = gl1
+ GIT_EXTRA_VERSION := gl1
endif
-ifndef GIT_BUILD_OPTIONS
+ifeq ($(origin GIT_BUILD_OPTIONS),undefined)
## Build options for Git.
GIT_BUILD_OPTIONS ?=
# activate developer checks
@@ -152,7 +152,7 @@ LIBGIT2_SOURCE_DIR ?= ${DEPENDENCY_DIR}/libgit2/source
LIBGIT2_BUILD_DIR ?= ${DEPENDENCY_DIR}/libgit2/build
LIBGIT2_INSTALL_DIR ?= ${DEPENDENCY_DIR}/libgit2/install
-ifndef LIBGIT2_BUILD_OPTIONS
+ifeq ($(origin LIBGIT2_BUILD_OPTIONS),undefined)
## Build options for libgit2.
LIBGIT2_BUILD_OPTIONS ?=
LIBGIT2_BUILD_OPTIONS += -DTHREADSAFE=ON
@@ -496,13 +496,13 @@ ${GIT_INSTALL_DIR}/bin/git: ${DEPENDENCY_DIR}/git.version
${Q}${GIT} -C "${GIT_SOURCE_DIR}" fetch --depth 1 ${GIT_QUIET} origin ${GIT_VERSION}
${Q}${GIT} -C "${GIT_SOURCE_DIR}" reset --hard
${Q}${GIT} -C "${GIT_SOURCE_DIR}" checkout ${GIT_QUIET} --detach FETCH_HEAD
-ifneq (${GIT_PATCHES},)
+ifdef GIT_PATCHES
${Q}${GIT} -C "${GIT_SOURCE_DIR}" apply $(addprefix "${SOURCE_DIR}"/_support/git-patches/,${GIT_PATCHES})
endif
${Q}# We're writing the version into the "version" file in Git's own source
${Q}# directory. If it exists, Git's Makefile will pick it up and use it as
${Q}# the version instead of auto-detecting via git-describe(1).
-ifneq (${GIT_EXTRA_VERSION},0)
+ifdef GIT_EXTRA_VERSION
${Q}echo ${GIT_VERSION}.${GIT_EXTRA_VERSION} >"${GIT_SOURCE_DIR}"/version
else
${Q}rm -f "${GIT_SOURCE_DIR}"/version