summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2018-06-27 19:35:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-06-29 16:04:10 (GMT)
commit5cf8e064747be2026bb23be37f84f2f0b2a31781 (patch)
treee7d82834faa3d149d9821fad636f5f3faa0a7e5f /Makefile
parented32b788c06973ef28440ef81fdde9e7e55667f1 (diff)
downloadgit-5cf8e064747be2026bb23be37f84f2f0b2a31781.zip
git-5cf8e064747be2026bb23be37f84f2f0b2a31781.tar.gz
git-5cf8e064747be2026bb23be37f84f2f0b2a31781.tar.bz2
Makefile: fix the "built from commit" code
In ed32b788c06 (version --build-options: report commit, too, if possible, 2017-12-15), we introduced code to let `git version --build-options` report the current commit from which the binaries were built, if any. To prevent erroneous commits from being reported (e.g. when unpacking Git's source code from a .tar.gz file into a subdirectory of a different Git project, as e.g. git_osx_installer does), we painstakingly set GIT_CEILING_DIRECTORIES when trying to determine the current commit. Except that we got the quoting wrong, and that variable therefore does not have the desired effect. The issue is that the $(shell) is resolved before the output is stuffed into the command-line with -DGIT_BUILT_FROM_COMMIT, and therefore is *not* inside quotes. And thus backslashing the quotes is wrong, as the quote gets literally inserted into the CEILING_DIRECTORIES variable. Let's fix that quoting, and while at it, also suppress the unhelpful message fatal: not a git repository (or any of the parent directories): .git that gets printed to stderr if no current commit could be determined, and might scare the occasional developer who simply tries to build Git from scratch. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile5
1 files changed, 3 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2ce70d2..afed47f 100644
--- a/Makefile
+++ b/Makefile
@@ -1903,8 +1903,9 @@ version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT
version.sp version.s version.o: EXTRA_CPPFLAGS = \
'-DGIT_VERSION="$(GIT_VERSION)"' \
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)' \
- '-DGIT_BUILT_FROM_COMMIT="$(shell GIT_CEILING_DIRECTORIES=\"$(CURDIR)/..\" \
- git rev-parse -q --verify HEAD || :)"'
+ '-DGIT_BUILT_FROM_COMMIT="$(shell \
+ GIT_CEILING_DIRECTORIES="$(CURDIR)/.." \
+ git rev-parse -q --verify HEAD 2>/dev/null)"'
$(BUILT_INS): git$X
$(QUIET_BUILT_IN)$(RM) $@ && \