Repository navigation
gh-159440: Pass --work-tree to the git commands used for the version tag - #159442
Merged
Merged
Conversation
sendaoYan
requested review from
AA-Turner,
corona10,
emmatyping,
erlend-aasland and
itamaro
as code owners
October 15, 2026 03:19
sendaoYan
force-pushed
the
issue-159440-dirty
branch
from
October 15, 2026 03:22
290cd22 to
ab9b474
Compare
…rsion tag --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.
sendaoYan
force-pushed
the
issue-159440-dirty
branch
from
October 15, 2026 03:43
ab9b474 to
c95ebcc
Compare
itamaro
approved these changes
Oct 15, 2026
itamaro
left a comment
Contributor
There was a problem hiding this comment.
looks good to me, thank you for the fix!
|
Thanks @sendaoYan for the PR, and @itamaro for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
GH-159443 is a backport of this pull request to the 3.15 branch. |
|
GH-159444 is a backport of this pull request to the 3.14 branch. |
itamaro
pushed a commit
that referenced
this pull request
Oct 15, 2026
…ersion 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 637fb36) Co-authored-by: sendaoYan <yansendao@hygon.cn>
itamaro
pushed a commit
that referenced
this pull request
Oct 15, 2026
…ersion tag (GH-159442) (#159443) 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 637fb36) Co-authored-by: sendaoYan <yansendao@hygon.cn>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
GITTAGbuild stamp usesgit --git-dir $(srcdir)/.git describe --all --always --dirty.--git-dirdoes not imply a work tree, so git falls back to the current directory. In an out-of-tree buildmakeruns in the build tree, where none of the tracked files exist, so the internaldiff-index HEADof--dirtyreports every tracked file as deleted and the tag always comes out asheads/<branch>-dirty— even for a pristine checkout. In-tree builds never hit this, andGITVERSION/GITBRANCHdon't touch the work tree, so only the dirty check was wrong.Pass
--work-tree $(srcdir)for all three commands. The semantics of-dirtyare preserved (a genuinely modified source tree still reports-dirty), and in-tree builds are unchanged because$(srcdir)is..Reproduce
sys.version reports a spurious -dirty git tag for out-of-tree builds, even when the checkout is pristine:
Root cause
GITTAG uses git --git-dir $(srcdir)/.git describe --all --always --dirty. --git-dir does not imply a work tree, so git falls back to the current directory. In an out-of-tree build make runs in the build directory, where none of the tracked files exist, and the internal diff-index HEAD behind --dirty reports every tracked file as deleted. GITVERSION and GITBRANCH never touch the work tree, so only the dirty check was wrong.
Change
All three git commands now get --work-tree $(srcdir):
The semantics of -dirty are preserved: a genuinely modified source tree still reports -dirty, and in-tree builds are unchanged because $(srcdir) is ..
Testing
Issue