From 29c3a39fd5647fef9dbea006de7a5e38a855dd05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 17 Nov 2021 11:20:18 +0100 Subject: [PATCH 1/4] Makefile: correct the dependency graph of hook-list.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix an issue in my cfe853e66be (hook-list.h: add a generated list of hooks, like config-list.h, 2021-09-26), the builtin/help.c was inadvertently made to depend on hook-list.h, but it's used by builtin/bugreport.c. The hook.c also does not depend on hook-list.h. It did in an earlier version of the greater series cfe853e66be was extracted from, but not anymore. We might end up needing that line again, but let's remove it for now. Reported-by: Mike Hommey Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 613da943b27d66..dc1ece46928484 100644 --- a/Makefile +++ b/Makefile @@ -2262,9 +2262,9 @@ git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS) $(filter %.o,$^) $(LIBS) help.sp help.s help.o: command-list.h -hook.sp hook.s hook.o: hook-list.h +builtin/bugreport.sp builtin/bugreport.s builtin/bugreport.o: hook-list.h -builtin/help.sp builtin/help.s builtin/help.o: config-list.h hook-list.h GIT-PREFIX +builtin/help.sp builtin/help.s builtin/help.o: config-list.h GIT-PREFIX builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \ '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \ '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \ From e7e8d9c75374b5aa2bbe3ebcb87a3e88e329fe39 Mon Sep 17 00:00:00 2001 From: Victoria Dye Date: Tue, 30 Nov 2021 14:40:06 -0500 Subject: [PATCH 2/4] Makefile: allow specifying GIT_BUILT_FROM_COMMIT Allow specification of a custom `GIT_BUILT_FROM_COMMIT` string to replace the output of `git rev-parse HEAD`. This allows a build of `git` from somewhere other than an active clone of `git` (e.g. from the archive created with `make dist`) to include commit information in `git version --build-options`. Signed-off-by: Victoria Dye --- .gitignore | 1 + Makefile | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index ce6cc6ebc76f67..2d7cfc6f0b3fae 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /fuzz-pack-headers /fuzz-pack-idx /GIT-BUILD-OPTIONS +/GIT-BUILT-FROM-COMMIT /GIT-CFLAGS /GIT-LDFLAGS /GIT-PREFIX diff --git a/Makefile b/Makefile index dc1ece46928484..f42027a0836bd0 100644 --- a/Makefile +++ b/Makefile @@ -390,6 +390,10 @@ all:: # Define GIT_USER_AGENT if you want to change how git identifies itself during # network interactions. The default is "git/$(GIT_VERSION)". # +# Define GIT_BUILT_FROM_COMMIT if you want to force the commit hash identified +# in 'git version --build-options' to a specific value. The default is the +# commit hash of the current HEAD. +# # Define DEFAULT_HELP_FORMAT to "man", "info" or "html" # (defaults to "man") if you want to have a different default when # "git help" is called without a parameter specifying the format. @@ -2147,6 +2151,15 @@ GIT-USER-AGENT: FORCE echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \ fi +GIT_BUILT_FROM_COMMIT = $(eval GIT_BUILT_FROM_COMMIT := $$(shell \ + GIT_CEILING_DIRECTORIES="$$(CURDIR)/.." \ + git rev-parse -q --verify HEAD 2>/dev/null))$(GIT_BUILT_FROM_COMMIT) +GIT-BUILT-FROM-COMMIT: FORCE + @if test x'$(GIT_BUILT_FROM_COMMIT)' != x"`cat GIT-BUILT-FROM-COMMIT 2>/dev/null`" ; then \ + echo >&2 " * new built-from commit"; \ + echo '$(GIT_BUILT_FROM_COMMIT)' >GIT-BUILT-FROM-COMMIT; \ + fi + ifdef DEFAULT_HELP_FORMAT BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"' endif @@ -2270,13 +2283,11 @@ builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \ '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \ '-DGIT_INFO_PATH="$(infodir_relative_SQ)"' -version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT +version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT GIT-BUILT-FROM-COMMIT 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 2>/dev/null)"' + '-DGIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)"' $(BUILT_INS): git$X $(QUIET_BUILT_IN)$(RM) $@ && \ From 131abfaaa54fc0924baf129ef3462bb07b743460 Mon Sep 17 00:00:00 2001 From: Victoria Dye Date: Thu, 2 Dec 2021 10:11:41 -0500 Subject: [PATCH 3/4] dist: archive HEAD instead of HEAD^{tree} Update `git archive` tree-ish argument from `HEAD^{tree}` to `HEAD`. By using a commit (rather than tree) reference, the commit hash will be stored as an extended pax header, extractable git `git get-tar-commit-id`. The intended use-case for this change is building `git` from the output of `make dist` - in combination with the ability to specify a fallback `GIT_BUILT_FROM_COMMIT`, a user can extract the commit ID used to build the archive and set it as `GIT_BUILT_FROM_COMMIT`. The result is fully-populated information for the commit hash in `git version --build-options`. Signed-off-by: Victoria Dye --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f42027a0836bd0..fdb423350eb25e 100644 --- a/Makefile +++ b/Makefile @@ -3274,7 +3274,7 @@ dist: git-archive$(X) configure @$(MAKE) -C git-gui TARDIR=../.dist-tmp-dir/git-gui dist-version ./git-archive --format=tar \ $(GIT_ARCHIVE_EXTRA_FILES) \ - --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar + --prefix=$(GIT_TARNAME)/ HEAD > $(GIT_TARNAME).tar @$(RM) -r .dist-tmp-dir gzip -f -9 $(GIT_TARNAME).tar From e64bb71f2c5cd06aa8304c0167c19f1058a2049d Mon Sep 17 00:00:00 2001 From: Victoria Dye Date: Thu, 2 Dec 2021 14:50:05 -0500 Subject: [PATCH 4/4] release: include GIT_BUILT_FROM_COMMIT in MacOS build Set the `GIT_BUILT_FROM_COMMIT` based on the version specified in the `make dist` output archive header. This ensures the commit hash is shown in `git version --build-options`. Signed-off-by: Victoria Dye --- .github/workflows/build-git-installers.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-git-installers.yml b/.github/workflows/build-git-installers.yml index 85fdd7be51a21d..663b468b162b69 100644 --- a/.github/workflows/build-git-installers.yml +++ b/.github/workflows/build-git-installers.yml @@ -354,6 +354,9 @@ jobs: cp git/git-$VERSION.tar.gz git/git-manpages-$VERSION.tar.gz git_osx_installer/build/ || die "Could not copy .tar.gz files" + GIT_BUILT_FROM_COMMIT=$(gunzip -c git/git-$VERSION.tar.gz | git get-tar-commit-id) || + die "Could not determine commit for build" + # drop the -isysroot `GIT_SDK` hack sed -i .bak -e 's/ -isysroot .(SDK_PATH)//' git_osx_installer/Makefile || die "Could not drop the -isysroot hack" @@ -371,6 +374,7 @@ jobs: PATH=/usr/local/bin:$PATH \ make -C git_osx_installer \ + GIT_BUILT_FROM_COMMIT=$GIT_BUILT_FROM_COMMIT \ OSX_VERSION=10.15 C_INCLUDE_PATH="$C_INCLUDE_PATH" V=1 image || die "Build failed"