[PATCH] D34955: [Basic] Detect Git submodule version in CMake
Jordan Rose via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 10 14:17:29 PDT 2017
jordan_rose added inline comments.
================
Comment at: lib/Basic/CMakeLists.txt:27
+ STRING(REGEX REPLACE "\n" "" file_contents "${file_contents}")
+ if ("${file_contents}" MATCHES "^gitdir:")
+ # '.git' is indeed a link to the submodule's Git directory.
----------------
How about
```
if("${file_contents}" MATCHES "^gitdir: ([^\n]+)")
set(git_path "${git_path}${CMAKE_MATCH_0}")
endif()
```
and then no stripping or replacing later at all? This admittedly doesn't handle some future submodule format that doesn't put `gitdir` on the first line, but neither does the code that's there.
(This also doesn't handle absolute path submodule references, but looking around a bit makes it sound like those aren't supposed to occur in practice and are considered bugs when git does generate them. I could be wrong about that though.)
https://reviews.llvm.org/D34955
More information about the cfe-commits
mailing list