Files
Patrick Steinhardt 4778070469 meson: fix outdated completion helpers
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-24 11:30:14 -07:00

27 lines
826 B
Meson

foreach script : [
'git-completion.bash',
'git-completion.tcsh',
'git-completion.zsh',
'git-prompt.sh'
]
# 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.
configure_file(
input: 'git-completion.bash',
output: 'git',
copy: true,
install: true,
install_dir: get_option('datadir') / 'bash-completion/completions',
)