[git] Fix switching branch of shallow clone (#18728)

* [git] Fix fetching branch of shallow clone

* Use absolute file:// paths to make sure git uses shallow clones

* Improve tests

* Fix sanity errors
* Match style according to other (depth) tests

* Improve tests

Now they will fail without the fix of this PR
This commit is contained in:
Maarten Bezemer 2018-02-08 00:07:02 +01:00 committed by Ryan Brown
parent 098eac076d
commit 7225839bef
3 changed files with 62 additions and 3 deletions

View file

@ -715,9 +715,7 @@ def fetch(git_path, module, repo, dest, version, remote, depth, bare, refspec, g
# 1.8.3 is broken, 1.9.x works
# ensure that remote branch is available as both local and remote ref
refspecs.append('+refs/heads/%s:refs/heads/%s' % (version, version))
refspecs.append('+refs/heads/%s:refs/remotes/%s/%s' % (version, remote, version))
else:
refspecs.append(version)
refspecs.append('+refs/heads/%s:refs/remotes/%s/%s' % (version, remote, version))
elif is_remote_tag(git_path, module, dest, repo, version):
refspecs.append('+refs/tags/' + version + ':refs/tags/' + version)
if refspecs: