From 5becb3d0793a1c0129b399471e682b7e41d2a43a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 7 Jul 2026 18:24:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Prevent=20git=20output=20with=20?= =?UTF-8?q?signature=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When users have something like [log] showSignature = true in their .gitconfig files, invocations of the log or show git sub-command emit additional information about signatures. This additional output disturbs the generation of the GIT_SHA and GIT_DATE values for the compiler command line. The additional text is copied verbatim into the file in unexpected places. The result is a parse error when invocing the compiler. To fix it always suppress the output of the signature information. This has no effects when the setting is disabled anyway. --- build.bat | 4 ++-- build_odin.sh | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.bat b/build.bat index 9cddcc375..66ce08bfd 100644 --- a/build.bat +++ b/build.bat @@ -21,7 +21,7 @@ if "%VSCMD_ARG_TGT_ARCH%" neq "x64" ( where /Q git.exe || goto skip_git_hash if not exist .git\ goto skip_git_hash -for /f "tokens=1,2" %%i IN ('git show "--pretty=%%cd %%h" "--date=format:%%Y-%%m-%%d" --no-patch --no-notes HEAD') do ( +for /f "tokens=1,2" %%i IN ('git -c log.showSignature=false show "--pretty=%%cd %%h" "--date=format:%%Y-%%m-%%d" --no-patch --no-notes HEAD') do ( set CURR_DATE_TIME=%%i set GIT_SHA=%%j ) @@ -138,4 +138,4 @@ if %release_mode% EQU 0 echo: & echo Debug compiler built. Note: run "build.bat del *.obj > NUL 2> NUL -:end_of_build \ No newline at end of file +:end_of_build diff --git a/build_odin.sh b/build_odin.sh index 7cd3de591..9eab985e9 100755 --- a/build_odin.sh +++ b/build_odin.sh @@ -17,8 +17,10 @@ OS_ARCH="$(uname -m)" OS_NAME="$(uname -s)" if [ -d ".git" ] && [ -n "$(command -v git)" ]; then - GIT_SHA=$(git show --pretty='%h' --no-patch --no-notes HEAD) - GIT_DATE=$(git show "--pretty=%cd" "--date=format:%Y-%m" --no-patch --no-notes HEAD) + # Counter the user's git config to show the signature in logs. + gitnosig="-c log.showSignature=false" + GIT_SHA=$(git $gitnosig show --pretty='%h' --no-patch --no-notes HEAD) + GIT_DATE=$(git $gitnosig show "--pretty=%cd" "--date=format:%Y-%m" --no-patch --no-notes HEAD) CPPFLAGS="$CPPFLAGS -DGIT_SHA=\"$GIT_SHA\"" else GIT_DATE=$(date +"%Y-%m")