blob: a65b35e5d294d9cfd239d48460518539bf5e60ae [file] [log] [blame]
John Keepinge1e0e032013-03-19 20:00:29 +00001#!/bin/sh
2
John Keepingc95cc5e2013-04-01 15:09:05 +01003test_description='Check Git version is correct'
4CGIT_TEST_NO_CREATE_REPOS=YesPlease
John Keepinge1e0e032013-03-19 20:00:29 +00005. ./setup.sh
6
John Keepingc95cc5e2013-04-01 15:09:05 +01007test_expect_success 'extract Git version from Makefile' '
John Keepinge1e0e032013-03-19 20:00:29 +00008 sed -n -e "/^GIT_VER[ ]*=/ {
9 s/^GIT_VER[ ]*=[ ]*//
10 p
John Keepingc95cc5e2013-04-01 15:09:05 +010011 }" ../../Makefile >makefile_version
John Keepinge1e0e032013-03-19 20:00:29 +000012'
13
John Keeping8d07ad32013-04-27 10:48:56 +010014# Note that Git's GIT-VERSION-GEN script applies "s/-/./g" to the version
15# string to produce the internal version in the GIT-VERSION-FILE, so we
16# must apply the same transformation to the version in the Makefile before
17# comparing them.
John Keepingc95cc5e2013-04-01 15:09:05 +010018test_expect_success 'test Git version matches Makefile' '
19 ( cat ../../git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) |
John Keepingd483e8f2013-04-14 19:15:43 +010020 sed -e "s/GIT_VERSION[ ]*=[ ]*//" -e "s/\\.dirty$//" >git_version &&
John Keeping8d07ad32013-04-27 10:48:56 +010021 sed -e "s/-/./g" makefile_version >makefile_git_version &&
22 test_cmp git_version makefile_git_version
John Keepinge1e0e032013-03-19 20:00:29 +000023'
24
John Keepingc95cc5e2013-04-01 15:09:05 +010025test_expect_success 'test submodule version matches Makefile' '
26 if ! test -e ../../git/.git
John Keepinge1e0e032013-03-19 20:00:29 +000027 then
28 echo "git/ is not a Git repository" >&2
29 else
30 (
John Keepingc95cc5e2013-04-01 15:09:05 +010031 cd ../.. &&
John Keepinge1e0e032013-03-19 20:00:29 +000032 sm_sha1=$(git ls-files --stage -- git |
33 sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\1/") &&
34 cd git &&
35 git describe --match "v[0-9]*" $sm_sha1
John Keepingc95cc5e2013-04-01 15:09:05 +010036 ) | sed -e "s/^v//" >sm_version &&
37 test_cmp sm_version makefile_version
John Keepinge1e0e032013-03-19 20:00:29 +000038 fi
39'
40
John Keepingc95cc5e2013-04-01 15:09:05 +010041test_done