code: def _get_branch_opts(branch, local_branch, all_local_branches,
                       desired_upstream, git_ver=None):
      '''
      DRY helper to build list of opts for git.branch, for the purposes of
      setting upstream tracking branch
      '''
      if branch is not None and branch not in all_local_branches:
          # We won't be setting upstream because the act of checking out a new
          # branch will set upstream for us
          return None
  
      if git_ver is None:
          git_ver = _LooseVersion(__salt__['git.version'](versioninfo=False))
  
      ret = []
      if git_ver >= _LooseVersion('1.8.0'):
          ret.extend(['--set-upstream-to', desired_upstream])
      else:
          ret.append('--set-upstream')
          # --set-upstream does not assume the current branch, so we have to
          # tell it which branch we'll be using
          ret.append(local_branch if branch is None else branch)
          ret.append(desired_upstream)
      return ref _get_branch_opts(branch, local_branch, all_local_branches,
                       desired_upstream, git_ver=None):
      '''
      DRY helper to build list of opts for git.branch, for the purposes of
      setting upstream tracking branch
      '''
      if branch is not None and branch not in all_local_branches:
          # We won't be setting upstream because the act of checking out a new
          # branch will set upstream for us
          return None
  
      if git_ver is None:
          git_ver = _LooseVersion(__salt__['git.version'](versioninfo=False))
  
      ret = []
      if git_ver >= _LooseVersion('1.8.0'):
          ret.extend(['--set-upstream-to', desired_upstream])
      else:
          ret.append('--set-upstream')
          # --set-upstream does not assume the current branch, so we have to
          # tell it which branch we'll be using
          ret.append(local_branch if branch is None else branch)
          ret.append(desired_upstream)
      return ret
docs: DRY helper to build list of opts for git.branch, for the purposes of
      setting upstream tracking branch