Skip to content

Commit 290cd22

Browse files
committed
gh-159440: Pass --work-tree to the git commands used for the version tag
The `GITTAG` build stamp 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 tree, where none of the tracked files exist, so the internal `diff-index HEAD` of `--dirty` reports every tracked file as deleted and the tag always comes out as `heads/<branch>-dirty` — even for a pristine checkout. In-tree builds never hit this, and `GITVERSION`/`GITBRANCH` don't touch the work tree, so only the dirty check was wrong. Pass `--work-tree \$(srcdir)` for all three commands. The semantics of `-dirty` are preserved (a genuinely modified source tree still reports `-dirty`), and in-tree builds are unchanged because `$(srcdir)` is `.`.
1 parent a6b4aa6 commit 290cd22

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎configure‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎configure.ac‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ HAS_GIT=no-repository
128128
fi
129129
if test $HAS_GIT = found
130130
then
131-
GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD"
132-
GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty"
133-
GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD"
131+
GITVERSION="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) rev-parse --short HEAD"
132+
GITTAG="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) describe --all --always --dirty"
133+
GITBRANCH="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) name-rev --name-only HEAD"
134134
else
135135
GITVERSION=""
136136
GITTAG=""

0 commit comments

Comments
 (0)