Permalink
Browse files

Ensuring the specified branch is what is cloned and checked out.

  • Loading branch information...
wayneeseguin committed Apr 1, 2016
1 parent 14ad4fd commit 744b5c9fa7becd4c376a472f5f1f83bc45717c0d
Showing with 10 additions and 1 deletion.
  1. +10 −1 core/internal/shell/vcs/handlers/git/functions
@@ -49,7 +49,7 @@ git_get()
then
if ! (
builtin cd "${repo_path}"
- git checkout --track "${remote}/${branch}" "${revision:-"HEAD"}" 2>&1 >/dev/null
+ git checkout "${remote}/${branch}" "${revision}" 2>&1 >/dev/null
)
then
fetch_error remote_branch_not_found
@@ -78,6 +78,15 @@ git_get()
if git clone "${_uri}" "${_target}" >/dev/null 2>&1
then
echo "${_uri}" > "${_target}/.uri"
+ # Ensure expected branch gets checked out.
+ if ! (
+ builtin cd "${_target}"
+ git fetch "${remote}" >/dev/null 2>&1
+ git checkout --track "${remote}/${branch}" 2>&1 >/dev/null
+ )
+ then
+ fetch_error remote_branch_not_found
+ fi
else
_uri_https="${_uri/git:\/\//https://}"

0 comments on commit 744b5c9

Please sign in to comment.