summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Junghans <christoph.junghans@gmail.com>2017-04-21 22:59:30 -0600
committerTodd Gamblin <tgamblin@llnl.gov>2017-04-21 21:59:30 -0700
commit0b002c2911845005c9c5f181f1cd5d77b8db1ec0 (patch)
treed1aa951ada4df4a8464b69ae1b9d6f2cf14b5f89
parent457268571086f921ea1034ec214511047a287ed3 (diff)
downloadspack-0b002c2911845005c9c5f181f1cd5d77b8db1ec0.tar.gz
spack-0b002c2911845005c9c5f181f1cd5d77b8db1ec0.tar.bz2
spack-0b002c2911845005c9c5f181f1cd5d77b8db1ec0.tar.xz
spack-0b002c2911845005c9c5f181f1cd5d77b8db1ec0.zip
fetch git submodules recursively (#3779)
* fetch git submodules recursively This is useful if the submodules have submodules themselves. On the other hand doing a recursive update doesn't hurt if there is only one level. * fetch submodules with depth=1 as well (fix #2190) * use git submodule with depth only for git>=1.8.4
-rw-r--r--lib/spack/docs/packaging_guide.rst5
-rw-r--r--lib/spack/spack/fetch_strategy.py16
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst
index 0e8ddfa68f..6f4a3ecf1a 100644
--- a/lib/spack/docs/packaging_guide.rst
+++ b/lib/spack/docs/packaging_guide.rst
@@ -854,7 +854,7 @@ Git fetching is enabled with the following parameters to ``version``:
* ``tag``: name of a tag to fetch.
* ``branch``: name of a branch to fetch.
* ``commit``: SHA hash (or prefix) of a commit to fetch.
-* ``submodules``: Also fetch submodules when checking out this repository.
+* ``submodules``: Also fetch submodules recursively when checking out this repository.
Only one of ``tag``, ``branch``, or ``commit`` can be used at a time.
@@ -917,7 +917,8 @@ Commits
Submodules
You can supply ``submodules=True`` to cause Spack to fetch submodules
- along with the repository at fetch time.
+ recursively along with the repository at fetch time. For more information
+ about git submodules see the manpage of git: ``man git-submodule``.
.. code-block:: python
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 7cafeb296d..c694610856 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -686,10 +686,20 @@ class GitFetchStrategy(VCSFetchStrategy):
# Init submodules if the user asked for them.
if self.submodules:
- if spack.debug:
- self.git('submodule', 'update', '--init')
+ # only git 1.8.4 and later have --depth option
+ if self.git_version < ver('1.8.4'):
+ if spack.debug:
+ self.git('submodule', 'update', '--init', '--recursive')
+ else:
+ self.git('submodule', '--quiet', 'update', '--init',
+ '--recursive')
else:
- self.git('submodule', '--quiet', 'update', '--init')
+ if spack.debug:
+ self.git('submodule', 'update', '--init', '--recursive',
+ '--depth=1')
+ else:
+ self.git('submodule', '--quiet', 'update', '--init',
+ '--recursive', '--depth=1')
def archive(self, destination):
super(GitFetchStrategy, self).archive(destination, exclude='.git')