diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index 48313e2b376..c892e9ea266 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -363,10 +363,6 @@ def __init__(self, **kwargs): 'git', 'tag', 'branch', 'commit', **kwargs) self._git = None - # For git fetch branches and tags the same way. - if not self.branch: - self.branch = self.tag - @property def git_version(self): @@ -422,6 +418,12 @@ def fetch(self): self.git(*args) self.stage.chdir_to_source() + # For tags, be conservative and check them out AFTER + # cloning. Later git versions can do this with clone + # --branch, but older ones fail. + if self.tag: + self.git('checkout', self.tag) + def archive(self, destination): super(GitFetchStrategy, self).archive(destination, exclude='.git')