GIT-BUILD-OPTIONS: propagate project's source directory

A couple of our tests require knowledge around where to find the project's source directory in order to locate files required for the test itself. Until now we have been wiring these up ad-hoc via new, specialized variables catered to the specific usecase. This is quite awkward though, as every test that potentially needs to locate paths relative to the source directory needs to grow another variable. Introduce a new "GIT_SOURCE_DIR" variable into GIT-BUILD-OPTIONS to stop this proliferation. Remove existing variables that can be derived from it. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Feb 18, 2025 at 08:45 UTC c5823641a6769a727d890a55160346d92808bc0c
6 files changed +6 -10
GIT-BUILD-OPTIONS.in
+1 -2
@@ -9,14 +9,13 @@ GIT_PERF_MAKE_COMMAND=@GIT_PERF_MAKE_COMMAND@
9 GIT_PERF_MAKE_OPTS=@GIT_PERF_MAKE_OPTS@
10 GIT_PERF_REPEAT_COUNT=@GIT_PERF_REPEAT_COUNT@
11 GIT_PERF_REPO=@GIT_PERF_REPO@
12 +GIT_SOURCE_DIR=@GIT_SOURCE_DIR@
13 GIT_TEST_CMP=@GIT_TEST_CMP@
14 GIT_TEST_CMP_USE_COPIED_CONTEXT=@GIT_TEST_CMP_USE_COPIED_CONTEXT@
15 GIT_TEST_GITPERLLIB=@GIT_TEST_GITPERLLIB@
16 GIT_TEST_INDEX_VERSION=@GIT_TEST_INDEX_VERSION@
16 -GIT_TEST_MERGE_TOOLS_DIR=@GIT_TEST_MERGE_TOOLS_DIR@
17 GIT_TEST_OPTS=@GIT_TEST_OPTS@
18 GIT_TEST_PERL_FATAL_WARNINGS=@GIT_TEST_PERL_FATAL_WARNINGS@
19 -GIT_TEST_POPATH=@GIT_TEST_POPATH@
19 GIT_TEST_TEMPLATE_DIR=@GIT_TEST_TEMPLATE_DIR@
20 GIT_TEST_TEXTDOMAINDIR=@GIT_TEST_TEXTDOMAINDIR@
21 GIT_TEST_UTF8_LOCALE=@GIT_TEST_UTF8_LOCALE@
Makefile
+1 -2
@@ -3192,14 +3192,13 @@ GIT-BUILD-OPTIONS: FORCE
3192 -e "s|@GIT_PERF_MAKE_OPTS@|\'$(GIT_PERF_MAKE_OPTS)\'|" \
3193 -e "s|@GIT_PERF_REPEAT_COUNT@|\'$(GIT_PERF_REPEAT_COUNT)\'|" \
3194 -e "s|@GIT_PERF_REPO@|\'$(GIT_PERF_REPO)\'|" \
3195 + -e "s|@GIT_SOURCE_DIR@|\'$(shell pwd)\'|" \
3196 -e "s|@GIT_TEST_CMP@|\'$(GIT_TEST_CMP)\'|" \
3197 -e "s|@GIT_TEST_CMP_USE_COPIED_CONTEXT@|\'$(GIT_TEST_CMP_USE_COPIED_CONTEXT)\'|" \
3198 -e "s|@GIT_TEST_GITPERLLIB@|\'$(shell pwd)/perl/build/lib\'|" \
3199 -e "s|@GIT_TEST_INDEX_VERSION@|\'$(GIT_TEST_INDEX_VERSION)\'|" \
3199 - -e "s|@GIT_TEST_MERGE_TOOLS_DIR@|\'$(shell pwd)/mergetools\'|" \
3200 -e "s|@GIT_TEST_OPTS@|\'$(GIT_TEST_OPTS)\'|" \
3201 -e "s|@GIT_TEST_PERL_FATAL_WARNINGS@|\'$(GIT_TEST_PERL_FATAL_WARNINGS)\'|" \
3202 - -e "s|@GIT_TEST_POPATH@|\'$(shell pwd)/po\'|" \
3202 -e "s|@GIT_TEST_TEMPLATE_DIR@|\'$(shell pwd)/templates/blt\'|" \
3203 -e "s|@GIT_TEST_TEXTDOMAINDIR@|\'$(shell pwd)/po/build/locale\'|" \
3204 -e "s|@GIT_TEST_UTF8_LOCALE@|\'$(GIT_TEST_UTF8_LOCALE)\'|" \
contrib/buildsystems/CMakeLists.txt
+1 -2
@@ -1169,14 +1169,13 @@ string(REPLACE "@GIT_PERF_MAKE_COMMAND@" "" git_build_options "${git_build_optio
1169 string(REPLACE "@GIT_PERF_MAKE_OPTS@" "" git_build_options "${git_build_options}")
1170 string(REPLACE "@GIT_PERF_REPEAT_COUNT@" "" git_build_options "${git_build_options}")
1171 string(REPLACE "@GIT_PERF_REPO@" "" git_build_options "${git_build_options}")
1172 +string(REPLACE "@GIT_SOURCE_DIR@" "${CMAKE_SOURCE_DIR}" git_build_options "${git_build_options}")
1173 string(REPLACE "@GIT_TEST_CMP@" "" git_build_options "${git_build_options}")
1174 string(REPLACE "@GIT_TEST_CMP_USE_COPIED_CONTEXT@" "" git_build_options "${git_build_options}")
1175 string(REPLACE "@GIT_TEST_GITPERLLIB@" "'${CMAKE_BINARY_DIR}/perl/build/lib'" git_build_options "${git_build_options}")
1176 string(REPLACE "@GIT_TEST_INDEX_VERSION@" "" git_build_options "${git_build_options}")
1176 -string(REPLACE "@GIT_TEST_MERGE_TOOLS_DIR@" "'${CMAKE_BINARY_DIR}/mergetools'" git_build_options "${git_build_options}")
1177 string(REPLACE "@GIT_TEST_OPTS@" "" git_build_options "${git_build_options}")
1178 string(REPLACE "@GIT_TEST_PERL_FATAL_WARNINGS@" "" git_build_options "${git_build_options}")
1179 -string(REPLACE "@GIT_TEST_POPATH@" "'${CMAKE_BINARY_DIR}/po'" git_build_options "${git_build_options}")
1179 string(REPLACE "@GIT_TEST_TEMPLATE_DIR@" "'${CMAKE_BINARY_DIR}/templates/blt'" git_build_options "${git_build_options}")
1180 string(REPLACE "@GIT_TEST_TEXTDOMAINDIR@" "'${CMAKE_BINARY_DIR}/po/build/locale'" git_build_options "${git_build_options}")
1181 string(REPLACE "@GIT_TEST_UTF8_LOCALE@" "" git_build_options "${git_build_options}")
meson.build
+1 -2
@@ -1960,10 +1960,9 @@ subdir('contrib')
1960
1961 foreach key, value : {
1962 'DIFF': diff.full_path(),
1963 + 'GIT_SOURCE_DIR': meson.project_source_root(),
1964 'GIT_TEST_CMP': diff.full_path() + ' -u',
1965 'GIT_TEST_GITPERLLIB': meson.project_build_root() / 'perl',
1965 - 'GIT_TEST_MERGE_TOOLS_DIR': meson.project_source_root() / 'mergetools',
1966 - 'GIT_TEST_POPATH': meson.project_source_root() / 'po',
1966 'GIT_TEST_TEMPLATE_DIR': meson.project_build_root() / 'templates',
1967 'GIT_TEST_TEXTDOMAINDIR': meson.project_build_root() / 'po',
1968 'PAGER_ENV': get_option('pager_environment'),
t/lib-gettext.sh
+1 -1
@@ -7,7 +7,7 @@
7 . ./test-lib.sh
8
9 GIT_TEXTDOMAINDIR="$GIT_TEST_TEXTDOMAINDIR"
10 -GIT_PO_PATH="$GIT_TEST_POPATH"
10 +GIT_PO_PATH="$GIT_SOURCE_DIR/po"
11 export GIT_TEXTDOMAINDIR GIT_PO_PATH
12
13 if test -n "$GIT_TEST_INSTALLED"
t/t7609-mergetool--lib.sh
+1 -1
@@ -7,7 +7,7 @@ Testing basic merge tools options'
7 . ./test-lib.sh
8
9 test_expect_success 'mergetool --tool=vimdiff creates the expected layout' '
10 - . "$GIT_TEST_MERGE_TOOLS_DIR"/vimdiff &&
10 + . "$GIT_SOURCE_DIR"/mergetools/vimdiff &&
11 run_unit_tests
12 '
13