From: Willy Tarreau Date: Fri, 16 Oct 2026 18:27:51 +0000 (+0200) Subject: BUILD: makefile: better support git worktrees X-Git-Tag: v3.5-dev10~129 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=a383051731cfa80f0196bdecc4c6a2ab7c1ea234;p=haproxy.git BUILD: makefile: better support git worktrees Git worktrees replace the .git directory with a file which contains the location to the git directory. The version generation test is based on the detection of .git/. as a directory, and thus fails inside a worktree. Let's relax the test to only see if .git exists. --- diff --git a/Makefile b/Makefile index 2d3dcee33..6bb0ff353 100644 --- a/Makefile +++ b/Makefile @@ -540,7 +540,7 @@ endif # holding the same names in the current directory. ifeq ($(IGNOREGIT),) - VERSION := $(shell [ -d .git/. ] && (git describe --tags --match 'v*' --abbrev=0 | cut -c 2-) 2>/dev/null) + VERSION := $(shell [ -e .git ] && (git describe --tags --match 'v*' --abbrev=0 | cut -c 2-) 2>/dev/null) ifneq ($(VERSION),) # OK git is there and works. SUBVERS := $(shell comms=`git log --format=oneline --no-merges v$(VERSION).. 2>/dev/null | wc -l | tr -d '[:space:]'`; commit=`(git log -1 --pretty=%h --abbrev=6) 2>/dev/null`; [ $$comms -gt 0 ] && echo "-$$commit-$$comms") @@ -1409,7 +1409,7 @@ unit-tests: # failure. range: - $(Q)[ -d .git/. ] || { echo "## Fatal: \"make $@\" may only be used inside a Git repository."; exit 1; } + $(Q)[ -e .git ] || { echo "## Fatal: \"make $@\" may only be used inside a Git repository."; exit 1; } $(Q)if git diff-index --name-only HEAD 2>/dev/null | grep -q ^; then \ echo "Fatal: \"make $@\" requires a clean working tree."; exit 1; fi