meson: fix git ls-files invocations during rebase

Normally ls-files prints the full path to files from the repo root. But when
$GIT_WORK_TREE is set, ls-files prints paths relative to the current
directory. When rebasing, $GIT_WORK_TREE is set in the commands executed from
'rebase -x'. This causes problems if meson config is touched and the meson
reconfigures itself. ($GIT_WORK_TREE shouldn't be relevant, since the paths that
ls-files reports don't depend on the work tree, but whatever.) Let's unset
GIT_WORK_TREE to avoid the issue.

$ (cd test; git --git-dir=$PWD/../.git ls-files ':/test/dmidecode-dumps/*.bin')
test/dmidecode-dumps/HP-Z600.bin
test/dmidecode-dumps/Lenovo-ThinkPad-X280.bin
test/dmidecode-dumps/Lenovo-Thinkcentre-m720s.bin

$ (cd test; GIT_WORK_TREE=$PWD/.. git --git-dir=$PWD/../.git ls-files ':/test/dmidecode-dumps/*.bin')
dmidecode-dumps/HP-Z600.bin
dmidecode-dumps/Lenovo-ThinkPad-X280.bin
dmidecode-dumps/Lenovo-Thinkcentre-m720s.bin

Fixes #18148.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-01-08 20:27:48 +01:00 committed by Yu Watanabe
parent 66bf4617b1
commit a412ec5714
3 changed files with 7 additions and 4 deletions

View File

@ -3651,10 +3651,11 @@ endforeach
if git.found()
all_files = run_command(
'env', '-u', 'GIT_WORK_TREE',
git,
['--git-dir=@0@/.git'.format(project_source_root),
'ls-files',
':/*.[ch]'])
'--git-dir=@0@/.git'.format(project_source_root),
'ls-files', ':/*.[ch]')
all_files = files(all_files.stdout().split())
custom_target(

View File

@ -23,6 +23,7 @@ sanitizers = [['address,undefined', sanitize_address_undefined]]
if git.found()
out = run_command(
'env', '-u', 'GIT_WORK_TREE',
git,
'--git-dir=@0@/.git'.format(project_source_root),
'ls-files', ':/test/fuzz/*/*')

View File

@ -142,6 +142,7 @@ if want_tests != 'false' and dmi_arches.contains(host_machine.cpu_family())
if git.found()
out = run_command(
'env', '-u', 'GIT_WORK_TREE',
git,
'--git-dir=@0@/.git'.format(project_source_root),
'ls-files', ':/test/dmidecode-dumps/*.bin')