MantisBT - CMake
View Issue Details
0015291CMakeCMakepublic2014-12-08 10:082016-06-10 14:21
Ilya 
Brad King 
normalfeaturehave not tried
closedfixed 
 
CMake 3.6CMake 3.6 
0015291: The ExternalProject should use the --depth option when working with git
Right now ExternalProject does full clone of both main repo and its submodules. It doesn't make sense since we're only interested in either most recent version of branch or specific commit.
No tags attached.
patch ExternalProject.patch (2,729) 2016-04-26 19:02
https://public.kitware.com/Bug/file/5683/ExternalProject.patch
Issue History
2014-12-08 10:08IlyaNew Issue
2014-12-08 11:11Brad KingNote Added: 0037405
2014-12-09 02:41IlyaNote Added: 0037421
2014-12-09 05:39IlyaNote Added: 0037422
2014-12-09 08:18Brad KingNote Added: 0037424
2014-12-09 12:43IlyaNote Added: 0037428
2014-12-09 15:22Brad KingNote Added: 0037430
2015-01-02 02:33IlyaNote Added: 0037542
2015-01-08 11:01Brad KingNote Added: 0037630
2015-10-10 12:28IlyaNote Added: 0039562
2016-04-26 19:02IlyaFile Added: ExternalProject.patch
2016-04-26 19:03IlyaNote Added: 0040931
2016-04-27 08:56Brad KingNote Added: 0040932
2016-04-27 08:56Brad KingAssigned To => Brad King
2016-04-27 08:56Brad KingStatusnew => resolved
2016-04-27 08:56Brad KingResolutionopen => fixed
2016-04-27 08:56Brad KingFixed in Version => CMake 3.6
2016-04-27 08:56Brad KingTarget Version => CMake 3.6
2016-04-27 10:14IlyaNote Added: 0040933
2016-04-27 10:23Brad KingNote Added: 0040934
2016-04-27 10:29IlyaNote Added: 0040935
2016-04-27 10:43Brad KingNote Added: 0040936
2016-04-27 10:50IlyaNote Added: 0040937
2016-04-27 10:58Brad KingNote Added: 0040938
2016-06-10 14:21Kitware RobotNote Added: 0041183
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0037405)
Brad King   
2014-12-08 11:11   
Some projects use ExternalProject just to configure a set of builds with Git work trees that a developer can then pick up and continue. Also as commits are added to the original repository the value of --depth needed to get back to the desired commit increases.

This could be added as a GIT_DEPTH option, but no depth should be used by default.
(0037421)
Ilya   
2014-12-09 02:41   
Maybe generic options like GIT_OPTIONS and GIT_SUBMODULE_OPTIONS would be better than just GIT_DEPTH?
(0037422)
Ilya   
2014-12-09 05:39   
By doing this we also address the issue, that CMake clones submodules without recursion.
(0037424)
Brad King   
2014-12-09 08:18   
The problem with generic options is that they need to define which command lines they apply to ("git fetch" v. "git clone" for example). Once we define such options then it restricts our ability to change the commands that are used underneath in the future.

One can always use DOWNLOAD_COMMAND and UPDATE_COMMAND with custom git calls.
(0037428)
Ilya   
2014-12-09 12:43   
@Brad I believe it's easier to install proper version of git rather than cmake to mitigate incompatibility.

With GIT_OPTIONS / GIT_SUBMODULE_OPTIONS a user will be able to fix options and move to the most recent version of git easily. If such options are hidden by cmake, user will be forced to use outdated version of git.
(0037430)
Brad King   
2014-12-09 15:22   
Re 0015291:0037428: This is not about Git version compatibility. It's about future flexibility of how the Git-based ExternalProject download and update steps are implemented. If we guarantee any specific commands will be used in order to honor GIT_OPTIONS then we will never be able to change to different/better commands to fix other problems or add other features. Users that want Git to be run a very specific way should just set DOWNLOAD_COMMAND and UPDATE_COMMAND themselves.

Declarative options like GIT_DEPTH or GIT_SUBMODULE_RECURSIVE can be added without forcing specific commands to be used underneath to honor them.
(0037542)
Ilya   
2015-01-02 02:33   
@Brad. Then I agree. Can we expect GIT_DEPTH/GIT_SUBMODULE_RECURSIVE in 3.1.1 ?
(0037630)
Brad King   
2015-01-08 11:01   
Re 0015291:0037542: 3.1.1 will only be for regression fixes.

If anyone wants to work on a patch to add this feature it can be considered as part of post-3.1 development.
(0039562)
Ilya   
2015-10-10 12:28   
Anyone?
(0040931)
Ilya   
2016-04-26 19:03   
Brad, attached the patch.

I added option called GIT_SHALLOW, because it's likely that developer needs either 1 or all commits.
(0040932)
Brad King   
2016-04-27 08:56   
Re 0015291:0040931: Thanks! I applied a change based on the patch here:

 ExternalProject: Add option to perform a shallow Git clone
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0209d234 [^]
(0040933)
Ilya   
2016-04-27 10:14   
Brad, I just realized that this option can only be used with branches. Worth to add to the docs.
(0040934)
Brad King   
2016-04-27 10:23   
Re 0015291:0040933: Thanks. Please propose wording for the GIT_SHALLOW docs that explains this, perhaps referencing the GIT_TAG option (which can name a branch, tag, or raw SHA-1).
(0040935)
Ilya   
2016-04-27 10:29   
What about:

    Tell Git to clone with ``--depth 1`` which will download the tip of a branch specified by GIT_TAG
(0040936)
Brad King   
2016-04-27 10:43   
Re 0015291:0040935: Thanks. How about?

    Tell Git to clone with ``--depth 1``. Use when ``GIT_TAG`` is not
    specified or when it names a branch in order to download only the
    tip of the branch without the rest of its history.

?
(0040937)
Ilya   
2016-04-27 10:50   
Looks good to me.
(0040938)
Brad King   
2016-04-27 10:58   
I've revised the commit with the updated docs:

 ExternalProject: Add option to perform a shallow Git clone
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7db9f3f2 [^]
(0041183)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.