Diff options
Diffstat (limited to 'tests/t0001-git-version.sh')
| -rwxr-xr-x | tests/t0001-git-version.sh | 18 |
1 file changed, 16 insertions, 2 deletions
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 |
