git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/1] Makefile: fix the "built from commit" code

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 27, 2018, 19:35 UTC
Message-ID
<e0e41d0b88b4104737b9ee80710c1bec91c9d759.1530190395.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.7.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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.

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>
---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 0cb6590f2..c70f823a0 100644
--- a/Makefile
+++ b/Makefile
@@ -2021,8 +2021,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) $@ && \
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Jeff King
Message 2 of 12 in “Makefile: fix the "built from commit" code”
  1. 0/1 Makefile: fix the "built from commit" codeJohannes Schindelin via GitGitGadget, Jun 28, 2018
  2. 1/1 Makefile: fix the "built from commit" codeJohannes Schindelin via GitGitGadget, Jun 27, 2018
  3. Jeff KingJun 28, 2018
  4. Johannes SchindelinJun 28, 2018
  5. Junio C HamanoJun 28, 2018
  6. Jeff KingJun 28, 2018
  7. Johannes SchindelinJun 29, 2018
  8. Jeff KingJun 28, 2018
  9. Johannes SchindelinJun 28, 2018
  10. brian m. carlsonJun 28, 2018
  11. 0/1 Fix "built from commit" logicJohannes Schindelin via GitGitGadget, Jun 29, 2018
  12. 1/1 Makefile: fix the "built from commit" codeJohannes Schindelin via GitGitGadget, Jun 27, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.