https://github.com/python/cpython/commit/65feab817fb1f6e37aaaeb8b29ed4d4a8d41d67e
commit: 65feab817fb1f6e37aaaeb8b29ed4d4a8d41d67e
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: itamaro <[email protected]>
date: 2026-10-15T04:45:03Z
summary:

[3.14] gh-159440: Pass --work-tree to the git commands used for the version tag 
(GH-159442) (#159444)

gh-159440: Pass --work-tree to the git commands used for the version tag 
(GH-159442)

`--git-dir` alone does not imply a work tree, so in an out-of-tree build
git checked the build directory, and every tracked file looked deleted:
`sys.version` always carried a spurious "-dirty" suffix.
(cherry picked from commit 637fb369c751efb0564e35757318e72874e21619)

Co-authored-by: sendaoYan <[email protected]>

files:
A Misc/NEWS.d/next/Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst
M configure
M configure.ac

diff --git 
a/Misc/NEWS.d/next/Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst 
b/Misc/NEWS.d/next/Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst
new file mode 100644
index 000000000000000..6c6cc43fd2e60d0
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst
@@ -0,0 +1,3 @@
+The version string reported by ``sys.version`` no longer carries a spurious
+``-dirty`` suffix when CPython is built out-of-tree from a clean git checkout:
+the build stamp now checks the source tree instead of the build directory.
diff --git a/configure b/configure
index 22a2639db6958d9..93339120cc454e5 100755
--- a/configure
+++ b/configure
@@ -3639,9 +3639,9 @@ HAS_GIT=no-repository
 fi
 if test $HAS_GIT = found
 then
-    GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD"
-    GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty"
-    GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD"
+    GITVERSION="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) rev-parse 
--short HEAD"
+    GITTAG="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) describe 
--all --always --dirty"
+    GITBRANCH="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) name-rev 
--name-only HEAD"
 else
     GITVERSION=""
     GITTAG=""
diff --git a/configure.ac b/configure.ac
index 963e6ccee0d0542..24089d0839ed6ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,9 +128,9 @@ HAS_GIT=no-repository
 fi
 if test $HAS_GIT = found
 then
-    GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD"
-    GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty"
-    GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD"
+    GITVERSION="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) rev-parse 
--short HEAD"
+    GITTAG="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) describe 
--all --always --dirty"
+    GITBRANCH="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) name-rev 
--name-only HEAD"
 else
     GITVERSION=""
     GITTAG=""

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to