diff options
-rw-r--r-- | src/luarocks/fetch/git.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index 49ee7183..88ba4848 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
@@ -50,6 +50,13 @@ local function git_supports_shallow_submodules(git_cmd) | |||
50 | return git_is_at_least(git_cmd, "1.8.4") | 50 | return git_is_at_least(git_cmd, "1.8.4") |
51 | end | 51 | end |
52 | 52 | ||
53 | --- Git >= 2.10 can fetch submodules shallowly according to .gitmodules configuration, allowing more granularity. | ||
54 | -- @param git_cmd string: name of git command. | ||
55 | -- @return boolean: Whether Git can fetch submodules shallowly according to .gitmodules. | ||
56 | local function git_supports_shallow_recommendations(git_cmd) | ||
57 | return git_is_at_least(git_cmd, "2.10.0") | ||
58 | end | ||
59 | |||
53 | local function git_identifier(git_cmd, ver) | 60 | local function git_identifier(git_cmd, ver) |
54 | if not (ver:match("^dev%-%d+$") or ver:match("^scm%-%d+$")) then | 61 | if not (ver:match("^dev%-%d+$") or ver:match("^scm%-%d+$")) then |
55 | return nil | 62 | return nil |
@@ -132,7 +139,9 @@ function git.get_sources(rockspec, extract, dest_dir, depth) | |||
132 | if rockspec:format_is_at_least("3.0") then | 139 | if rockspec:format_is_at_least("3.0") then |
133 | command = {fs.Q(git_cmd), "submodule", "update", "--init", "--recursive"} | 140 | command = {fs.Q(git_cmd), "submodule", "update", "--init", "--recursive"} |
134 | 141 | ||
135 | if git_supports_shallow_submodules(git_cmd) then | 142 | if git_supports_shallow_recommendations(git_cmd) then |
143 | table.insert(command, 5, "--recommend-shallow") | ||
144 | elseif git_supports_shallow_submodules(git_cmd) then | ||
136 | -- Fetch only the last commit of each submodule. | 145 | -- Fetch only the last commit of each submodule. |
137 | table.insert(command, 5, "--depth=1") | 146 | table.insert(command, 5, "--depth=1") |
138 | end | 147 | end |