[PATCH 5/7] meson: fix outdated completion helpers
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Sep 24, 2026, 14:09 UTC
- Message-ID
- <20260924-pks-meson-improvements-v1-5-90b7f79f1c4e@pks.im>
- In-Reply-To
- <20260924-pks-meson-improvements-v1-0-90b7f79f1c4e@pks.im>
When using Meson 1.3.0 or newer, we use `fs.copyfile()` to put our completion helpers into the expected location so that our test suite can find these scripts. Naturally, we thus also add these scripts to our test dependencies so that we know to build them before executing tests. But there's an issue here: we include the "contrib/completion" subdir after we have already wired up our tests, so any dependencies we add here are not being honored correctly. This has the consequence that we don't know to copy around these completion helpers when we execute tests, and one has to manually `meson compile` beforehand.
The interesting part here is that the code path we use with older versions of Meson don't suffer from the same problem as they use `configure_file()`, and that function will always run whenever the source file changes. It's conceptually correct to use `fs.copyfile()` instead, but given that it's mostly creating problems for us it does not really seem sensible to continue using it.
Adapt the build instructions to unconditionally use `configure_file()` to fix this issue.
A better fix would arguably be to promote our shell completion helpers out of "contrib/" -- they are an important part of Git nowadays, and these helpers get installed on lots of platforms. If so, we could also fix the order of subdir includes so that test dependencies are properly honored. But that feels like a bigger change, so that's left for a future patch series.
Signed-off-by: Patrick Steinhardt <ps@pks.im> --- contrib/completion/meson.build | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-)
diff --git a/contrib/completion/meson.build b/contrib/completion/meson.build index 576125b083..4483c5be3e 100644 --- a/contrib/completion/meson.build +++ b/contrib/completion/meson.build @@ -4,31 +4,23 @@ foreach script : [ 'git-completion.zsh', 'git-prompt.sh' ] - if meson.version().version_compare('>=1.3.0') - test_dependencies += fs.copyfile(script) - else - configure_file( - input: script, - output: script, - copy: true, - ) - endif + # Note that we intentionally don't use `fs.copyfile()` here because we'd have + # to add it to our test dependencies in that case, but that creates a + # chicken-and-egg situation between including "t/" or "contrib/" first. + configure_file( + input: script, + output: script, + copy: true, + ) endforeach # We have to discern between the test dependency and the installed file. Our # tests assume the completion scripts to have the same name as the in-tree # files, but the installed filenames need to match the executable's basename. -if meson.version().version_compare('>=1.3.0') - fs.copyfile('git-completion.bash', 'git', - install: true, - install_dir: get_option('datadir') / 'bash-completion/completions', - ) -else - configure_file( - input: 'git-completion.bash', - output: 'git', - copy: true, - install: true, - install_dir: get_option('datadir') / 'bash-completion/completions', - ) -endif +configure_file( + input: 'git-completion.bash', + output: 'git', + copy: true, + install: true, + install_dir: get_option('datadir') / 'bash-completion/completions', +)
-- 2.56.0.rc2.329.gd58861e689.dirty