diff options
author | Brad King <brad.king@kitware.com> | 2010-07-27 15:31:59 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-07-27 15:31:59 (GMT) |
commit | a7319cf1c155a0e82c88689c0b4fe54b389a580e (patch) | |
tree | 2d081bad79905906155d49925637e6003a13dbcb /Source/CTest/cmCTestGIT.cxx | |
parent | 7bf8dc1ac9d2c2430e247c2cfb54a6a4cb5f698a (diff) | |
download | CMake-a7319cf1c155a0e82c88689c0b4fe54b389a580e.zip CMake-a7319cf1c155a0e82c88689c0b4fe54b389a580e.tar.gz CMake-a7319cf1c155a0e82c88689c0b4fe54b389a580e.tar.bz2 |
ctest_update: Run 'git submodule' at top level
The git submodule porcelain must be executed from the top level of the
work tree. Use 'git rev-parse --show-cdup' to find the top level
relative to the source tree. This is better than searching up the tree
for .git ourselves because it will always work the same way Git does and
thus honors settings like GIT_DISCOVERY_ACROSS_FILESYSTEM.
Diffstat (limited to 'Source/CTest/cmCTestGIT.cxx')
-rw-r--r-- | Source/CTest/cmCTestGIT.cxx | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index e44f81d..0fbc92e 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -133,6 +133,27 @@ std::string cmCTestGIT::FindGitDir() } //---------------------------------------------------------------------------- +std::string cmCTestGIT::FindTopDir() +{ + std::string top_dir = this->SourceDirectory; + + // Run "git rev-parse --show-cdup" to locate the top of the tree. + const char* git = this->CommandLineTool.c_str(); + char const* git_rev_parse[] = {git, "rev-parse", "--show-cdup", 0}; + std::string cdup; + OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup); + OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); + if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) && + !cdup.empty()) + { + top_dir += "/"; + top_dir += cdup; + top_dir = cmSystemTools::CollapseFullPath(top_dir.c_str()); + } + return top_dir; +} + +//---------------------------------------------------------------------------- bool cmCTestGIT::UpdateByFetchAndReset() { const char* git = this->CommandLineTool.c_str(); @@ -240,11 +261,13 @@ bool cmCTestGIT::UpdateImpl() return false; } + std::string top_dir = this->FindTopDir(); const char* git = this->CommandLineTool.c_str(); char const* git_submodule[] = {git, "submodule", "update", 0}; OutputLogger submodule_out(this->Log, "submodule-out> "); OutputLogger submodule_err(this->Log, "submodule-err> "); - return this->RunChild(git_submodule, &submodule_out, &submodule_err); + return this->RunChild(git_submodule, &submodule_out, &submodule_err, + top_dir.c_str()); } //---------------------------------------------------------------------------- |