From 4246059f7c27bdcec379321994ca78dd3abd03ed Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 17:32:46 -1000 Subject: Check the submodule pin against the Makefile The commit named is the one Git's v2.56.0 tag peels to upstream. --- tests/t0001-git-version.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tests/t0001-git-version.sh') diff --git a/tests/t0001-git-version.sh b/tests/t0001-git-version.sh index 552b2c6..b90ec74 100755 --- a/tests/t0001-git-version.sh +++ b/tests/t0001-git-version.sh @@ -2,8 +2,8 @@ # Checks that the Git version cgit says it is built for is the one it is # built against, so the Makefile, vendor/git and the submodule pin must name -# the same version. Set CGIT_TEST_NO_GIT_VERSION to YesPlease when Git comes -# from elsewhere. +# the same version, and the pin must be the commit the Makefile names. Set +# CGIT_TEST_NO_GIT_VERSION to YesPlease when Git comes from elsewhere. test_description='Check Git version is correct' CGIT_TEST_NO_CREATE_REPOS=YesPlease @@ -48,4 +48,18 @@ test_expect_success SUBMODULE 'test submodule version matches Makefile' ' test_cmp makefile_version submodule_version ' +# The Makefile names the commit as well, so the pin can be checked from the +# index alone, with or without the submodule. A tree that is not a checkout +# has no index to read and skips it. +test_lazy_prereq CHECKOUT 'test -e "$TEST_OUTPUT_DIRECTORY/../.git"' + +test_expect_success CHECKOUT 'test submodule commit matches Makefile' ' + sed -n "s/^GIT_COMMIT[[:space:]]*=[[:space:]]*//p" \ + "$TEST_OUTPUT_DIRECTORY/../Makefile" >makefile_commit && + test -s makefile_commit && + git -C "$TEST_OUTPUT_DIRECTORY/.." ls-files --stage -- vendor/git >gitlink && + sed -n "s/^160000 \\([0-9a-f]*\\) .*/\\1/p" gitlink >submodule_commit && + test_cmp makefile_commit submodule_commit +' + test_done -- cgit 2.12.1