[Cmake-commits] CMake branch, next, updated. v3.5.2-1092-g5a97238

Brad King brad.king at kitware.com
Wed Apr 27 08:55:35 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  5a9723862ce1e27f750000d4f6fb0ae91aab1b8a (commit)
       via  0209d23481bc5bfe0d7e4d40e0b8249083f9d50c (commit)
       via  b8a8dfec3688f1dc44f95528a65135fc76511c7b (commit)
      from  a7e7a045f88eaa2379e5b6126ce4e4b042739c92 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5a9723862ce1e27f750000d4f6fb0ae91aab1b8a
commit 5a9723862ce1e27f750000d4f6fb0ae91aab1b8a
Merge: a7e7a045 0209d23
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 27 08:55:33 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Apr 27 08:55:33 2016 -0400

    Merge topic 'ExternalProject-git-clone-shallow' into next
    
    0209d234 ExternalProject: Add option to perform a shallow Git clone (#15291)
    b8a8dfec CMake Nightly Date Stamp


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0209d23481bc5bfe0d7e4d40e0b8249083f9d50c
commit 0209d23481bc5bfe0d7e4d40e0b8249083f9d50c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 27 08:47:32 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Apr 27 08:54:37 2016 -0400

    ExternalProject: Add option to perform a shallow Git clone (#15291)
    
    Inspired-by: Ilya Kulakov <kulakov.ilya at gmail.com>

diff --git a/Help/release/dev/ExternalProject-git-clone-shallow.rst b/Help/release/dev/ExternalProject-git-clone-shallow.rst
new file mode 100644
index 0000000..f06fe34
--- /dev/null
+++ b/Help/release/dev/ExternalProject-git-clone-shallow.rst
@@ -0,0 +1,5 @@
+ExternalProject-git-clone-shallow
+---------------------------------
+
+* The :module:`ExternalProject` module leared the ``GIT_SHALLOW 1``
+  option to perform a shallow clone of a Git repository.
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 1f3dc38..3198511 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -61,6 +61,9 @@ Create custom targets to build projects in external trees
     The optional name of the remote, default to ``origin``
   ``GIT_SUBMODULES <module>...``
     Git submodules that shall be updated, all if empty
+  ``GIT_SHALLOW 1``
+    Tell Git to clone with ``--depth 1`` to download only the most
+    recent commit of the repository and its submodules.
   ``HG_REPOSITORY <url>``
     URL of mercurial repo
   ``HG_TAG <tag>``
@@ -499,7 +502,12 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
   "ExternalProject module."
   )
 
-function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
+function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
+  if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10)
+    set(git_clone_shallow_options "--depth 1 --no-single-branch")
+  else()
+    set(git_clone_shallow_options "--depth 1")
+  endif()
   file(WRITE ${script_filename}
 "if(\"${git_tag}\" STREQUAL \"\")
   message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
@@ -533,12 +541,19 @@ if(NOT \"x${tls_verify}\" STREQUAL \"x\" AND NOT tls_verify)
     -c http.sslVerify=false)
 endif()
 
+set(git_clone_options)
+
+set(git_shallow \"${git_shallow}\")
+if(git_shallow)
+  list(APPEND git_clone_options ${git_clone_shallow_options})
+endif()
+
 # try the clone 3 times incase there is an odd git clone issue
 set(error_code 1)
 set(number_of_tries 0)
 while(error_code AND number_of_tries LESS 3)
   execute_process(
-    COMMAND \"${git_EXECUTABLE}\" \${git_options} clone --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\"
+    COMMAND \"${git_EXECUTABLE}\" \${git_options} clone \${git_clone_options} --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\"
     WORKING_DIRECTORY \"${work_dir}\"
     RESULT_VARIABLE error_code
     )
@@ -1793,6 +1808,7 @@ function(_ep_add_download_command name)
     if("x${tls_verify}" STREQUAL "x" AND DEFINED CMAKE_TLS_VERIFY)
       set(tls_verify "${CMAKE_TLS_VERIFY}")
     endif()
+    get_property(git_shallow TARGET ${name} PROPERTY _EP_GIT_SHALLOW)
 
     # For the download step, and the git clone operation, only the repository
     # should be recorded in a configured RepositoryInfo file. If the repo
@@ -1817,7 +1833,7 @@ function(_ep_add_download_command name)
     # The script will delete the source directory and then call git clone.
     #
     _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
-      ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" ${src_name} ${work_dir}
+      ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" ${src_name} ${work_dir}
       ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}"
       )
     set(comment "Performing download step (git clone) for '${name}'")
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index b5041c7..ca6462d 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -349,6 +349,20 @@ if(do_git_tests)
   )
   set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
 
+  # Live git / master (no GIT_TAG), but shallow
+  #
+  set(proj TutorialStep1-GIT-shallow-master)
+  ExternalProject_Add(${proj}
+    GIT_REPOSITORY "${local_git_repo}"
+    GIT_SHALLOW 1
+    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
+    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+    INSTALL_COMMAND ""
+    DEPENDS "SetupLocalGITRepository"
+    LOG_UPDATE 1
+  )
+  set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
+
   # git by explicit branch/tag with empty submodule list
   #
   set(proj TutorialStep1-GIT-bytag-withsubmodules)
@@ -543,6 +557,9 @@ if(do_git_tests)
   add_test(TutorialStep1-GIT-bytag
     "${binary_base}/TutorialStep1-GIT-bytag/Tutorial" 99)
 
+  add_test(TutorialStep1-GIT-shallow-master
+    "${binary_base}/TutorialStep1-GIT-shallow-master/Tutorial" 98)
+
   add_test(TutorialStep1-GIT-master
     "${binary_base}/TutorialStep1-GIT-master/Tutorial" 98)
 endif()

-----------------------------------------------------------------------

Summary of changes:
 .../dev/ExternalProject-git-clone-shallow.rst      |    5 +++++
 Modules/ExternalProject.cmake                      |   22 +++++++++++++++++---
 Source/CMakeVersion.cmake                          |    2 +-
 Tests/ExternalProject/CMakeLists.txt               |   17 +++++++++++++++
 4 files changed, 42 insertions(+), 4 deletions(-)
 create mode 100644 Help/release/dev/ExternalProject-git-clone-shallow.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list