def set_remote_branch(git_path, module, dest, remote, version, depth):
 branchref = ('+refs/heads/%s:refs/heads/%s' % (version, version))
 branchref += (' +refs/heads/%s:refs/remotes/%s/%s' % (version, remote, version))
 cmd = ('%s fetch --depth=%s %s %s' % (git_path, depth, remote, branchref))
 (rc, out, err) = module.run_command(cmd, cwd=dest)
 if (rc != 0):
  module.fail_json(msg=('Failed to fetch branch from remote: %s' % version), stdout=out, stderr=err, rc=rc)

def set_remote_branch ( git_path , module , dest , remote , version , depth ) : branchref = ( '+refs/heads/%s:refs/heads/%s' % ( version , version ) ) branchref += ( ' +refs/heads/%s:refs/remotes/%s/%s' % ( version , remote , version ) ) cmd = ( '%s fetch --depth=%s %s %s' % ( git_path , depth , remote , branchref ) ) ( rc , out , err ) = module . run_command ( cmd , cwd = dest ) if ( rc != 0 ) : module . fail_json ( msg = ( 'Failed to fetch branch from remote: %s' % version ) , stdout = out , stderr = err , rc = rc )
set refs for the remote branch version this assumes the branch does not yet exist locally and is therefore also not checked out .