diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2016-03-31 16:30:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-04-01 19:50:31 (GMT) |
commit | 7f5607439ed0d1303265d3db0937e90683e698de (patch) | |
tree | 03cedef163fe8ffa056c9247e5a5b096c3d6a94e /Source/CTest | |
parent | 06b310b5d5d8a38fb17df02fee8df750904cfcd0 (diff) | |
download | CMake-7f5607439ed0d1303265d3db0937e90683e698de.zip CMake-7f5607439ed0d1303265d3db0937e90683e698de.tar.gz CMake-7f5607439ed0d1303265d3db0937e90683e698de.tar.bz2 |
cmCTestGIT: run `git submodule sync` before updating submodules
If the URL of a submodule changes upstream, the commits referenced at
the old URL may not be available and will cause an update failure.
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestGIT.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 9ee18e6..1d6bdce 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -273,6 +273,7 @@ bool cmCTestGIT::UpdateImpl() std::string top_dir = this->FindTopDir(); const char* git = this->CommandLineTool.c_str(); const char* recursive = "--recursive"; + const char* sync_recursive = "--recursive"; // Git < 1.6.5 did not support submodule --recursive if(this->GetGitVersion() < cmCTestGITVersion(1,6,5,0)) @@ -285,6 +286,17 @@ bool cmCTestGIT::UpdateImpl() } } + // Git < 1.8.1 did not support sync --recursive + if(this->GetGitVersion() < cmCTestGITVersion(1,8,1,0)) + { + sync_recursive = 0; + // No need to require >= 1.8.1 if there are no submodules. + if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) + { + this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n"; + } + } + OutputLogger submodule_out(this->Log, "submodule-out> "); OutputLogger submodule_err(this->Log, "submodule-err> "); @@ -304,6 +316,16 @@ bool cmCTestGIT::UpdateImpl() } } + char const* git_submodule_sync[] = {git, "submodule", "sync", + sync_recursive, 0}; + ret = this->RunChild(git_submodule_sync, &submodule_out, &submodule_err, + top_dir.c_str()); + + if (!ret) + { + return false; + } + char const* git_submodule[] = {git, "submodule", "update", recursive, 0}; return this->RunChild(git_submodule, &submodule_out, &submodule_err, top_dir.c_str()); |