def _get_envs_from_ref_paths(self, refs):
        '''
        Return the names of remote refs (stripped of the remote name) and tags
        which are map to the branches and tags.
        '''
        def _check_ref(env_set, rname):
            '''
            Add the appropriate saltenv(s) to the set
            '''
            if rname in self.saltenv_revmap:
                env_set.update(self.saltenv_revmap[rname])
            else:
                if rname == self.base:
                    env_set.add('base')
                elif not self.disable_saltenv_mapping:
                    env_set.add(rname)

        use_branches = 'branch' in self.ref_types
        use_tags = 'tag' in self.ref_types

        ret = set()
        if salt.utils.stringutils.is_hex(self.base):
            # gitfs_base or per-saltenv 'base' may point to a commit ID, which
            # would not show up in the refs. Make sure we include it.
            ret.add('base')
        for ref in salt.utils.data.decode(refs):
            if ref.startswith('refs/'):
                ref = ref[5:]
            rtype, rname = ref.split('/', 1)
            if rtype == 'remotes' and use_branches:
                parted = rname.partition('/')
                rname = parted[2] if parted[2] else parted[0]
                _check_ref(ret, rname)
            elif rtype == 'tags' and use_tags:
                _check_ref(ret, rname)

        return ret