[PATCH] build: parsing "git log" breaks with gpg signature verification

Bjørn Mork bjorn at mork.no
Tue Feb 11 10:05:32 PST 2025


Parsing "git log" is fragile.  The actual output depends on both global and
local configuration files. Enabling "log.showSignature" makes "git log" prefix
signed commits with multiple lines of gpg verify output, regardless of the
configured log format.

Add "--no-show-signature" to "git log" commands to work around this particular
issue.

Signed-off-by: Bjørn Mork <bjorn at mork.no>
---
 include/download.mk | 2 +-
 rules.mk            | 4 ++--
 scripts/getver.sh   | 2 +-
 toolchain/Makefile  | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/download.mk b/include/download.mk
index 7f3430277350..3ed88bb9528d 100644
--- a/include/download.mk
+++ b/include/download.mk
@@ -228,7 +228,7 @@ define DownloadMethod/rawgit
 	[ \! -d $(SUBDIR) ] && \
 	git clone $(OPTS) $(URL) $(SUBDIR) && \
 	(cd $(SUBDIR) && git checkout $(SOURCE_VERSION)) && \
-	export TAR_TIMESTAMP=`cd $(SUBDIR) && git log -1 --format='@%ct'` && \
+	export TAR_TIMESTAMP=`cd $(SUBDIR) && git log -1 --no-show-signature --format='@%ct'` && \
 	echo "Generating formal git archive (apply .gitattributes rules)" && \
 	(cd $(SUBDIR) && git config core.abbrev 8 && \
 	git archive --format=tar HEAD --output=../$(SUBDIR).tar.git) && \
diff --git a/rules.mk b/rules.mk
index dbc448e1a432..7a5df4109ef1 100644
--- a/rules.mk
+++ b/rules.mk
@@ -507,9 +507,9 @@ ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))
 ##
 define commitcount
 $(shell \
-  if git log -1 >/dev/null 2>/dev/null; then \
+  if git log -1 --no-show-signature >/dev/null 2>/dev/null; then \
     if [ -n "$(1)" ]; then \
-      last_bump="$$(git log --pretty=format:'%h %s' . | \
+      last_bump="$$(git log --no-show-signature --pretty=format:'%h %s' . | \
         grep -m 1 -e ': [uU]pdate to ' -e ': [bB]ump to ' | \
         cut -f 1 -d ' ')"; \
     fi; \
diff --git a/scripts/getver.sh b/scripts/getver.sh
index 0659d8004a01..23ca0f489b15 100755
--- a/scripts/getver.sh
+++ b/scripts/getver.sh
@@ -40,7 +40,7 @@ try_git() {
 			REV="${UPSTREAM_REV}+$((REV - UPSTREAM_REV))"
 		fi
 
-		REV="${REV:+r$REV-$(git log -n 1 --format="%h" $UPSTREAM_BASE)}"
+		REV="${REV:+r$REV-$(git log -n 1 --no-show-signature --format="%h" $UPSTREAM_BASE)}"
 
 		;;
 	esac
diff --git a/toolchain/Makefile b/toolchain/Makefile
index 09c16f72a780..67b1540117cd 100644
--- a/toolchain/Makefile
+++ b/toolchain/Makefile
@@ -65,7 +65,7 @@ endif
 ifdef CONFIG_BUILDBOT
 ifneq ($(wildcard $(TOPDIR)/.git),)
   $(TOOLCHAIN_DIR)/stamp/.ver_check: $(TMP_DIR)/.build
-	cd "$(TOPDIR)"; git log --format=%h -1 toolchain > $(TMP_DIR)/.ver_check
+	cd "$(TOPDIR)"; git log --no-show-signature --format=%h -1 toolchain > $(TMP_DIR)/.ver_check
 	cmp -s $(TMP_DIR)/.ver_check $@ || { \
 		rm -rf $(BUILD_DIR) $(STAGING_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR_TOOLCHAIN); \
 		mkdir -p $(TOOLCHAIN_DIR)/stamp; \
-- 
2.39.5




More information about the openwrt-devel mailing list