-run_test 'test Git version matches Makefile' '
- ( cat ../git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) |
- sed -e "s/GIT_VERSION[ ]*=[ ]*//" >trash/git_version &&
- diff -u trash/git_version trash/makefile_version
+# Note that Git's GIT-VERSION-GEN script applies "s/-/./g" to the version
+# string to produce the internal version in the GIT-VERSION-FILE, so we
+# must apply the same transformation to the version in the Makefile before
+# comparing them.
+test_expect_success 'test Git version matches Makefile' '
+ ( cat ../../git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) |
+ sed -e "s/GIT_VERSION[ ]*=[ ]*//" -e "s/\\.dirty$//" >git_version &&
+ sed -e "s/-/./g" makefile_version >makefile_git_version &&
+ test_cmp git_version makefile_git_version