get branches from the branchlist
323049
def branchlist2branches(data, commdct, branchlist):
    """"""
    objkey = 'BranchList'.upper()
    theobjects = data.dt[objkey]
    fieldlists = []
    objnames = [obj[1] for obj in theobjects]
    for theobject in theobjects:
        fieldlists.append(list(range(2, len(theobject))))
    blists = extractfields(data, commdct, objkey, fieldlists)
    thebranches = [branches for name, branches in zip(objnames, blists)
                   if name == branchlist]
    return thebranches[0]
1351700
def release_branches(self):
        """"""
        self.ensure_release_scheme('branches')
        return dict((r.revision.branch, r) for r in self.releases.values())
1035150
def find_branches_raw(self):
        """"""
        listing = self.context.capture('git', 'for-each-ref', '--format=%(refname)\t%(objectname)')
        for line in listing.splitlines():
            match = FOR_EACH_REF_PATTERN.match(line)
            if match and match.group('name') != 'HEAD':
                yield (match.group('prefix'),
                       match.group('name'),
                       match.group('revision_id'))
504673
def by_branch(branch, cmd_options={})
      hg_to_array(["log -b ? --style ?", branch, style], {:separator => changeset_separator}, cmd_options) do |line|
        build(line)
      end
    end
330583
def branches(self) -> Set[str]:
        
        if self._branches is None:
            self._branches = self._get_branches()

        return self._branches
1253201
def repo_branches(self, repo):
        
        branches = []
        try:
            # switch to directory where repo will be cloned to
            status = self.path_dirs.apply_path(repo)
            if status[0]:
                cwd = status[1]
            else:
                self.logger.error('apply_path failed. Exiting repo_branches'
                                  ' with status ' + str(status))
                return status

            branch_output = check_output(shlex.split('git branch -a'),
                                         stderr=STDOUT,
                                         close_fds=True)
            branch_output = branch_output.split(b'\n')
            for branch in branch_output:
                br = branch.strip()
                if br.startswith(b'*'):
                    br = br[2:]
                if b'/' in br:
                    branches.append(br.rsplit(b'/', 1)[1].decode('utf-8'))
                elif br:
                    branches.append(br.decode('utf-8'))

            branches = list(set(branches))
            for branch in branches:
                try:
                    check_output(shlex.split('git checkout ' + branch),
                                 stderr=STDOUT,
                                 close_fds=True)
                except Exception as e:  # pragma: no cover
                    self.logger.error('repo_branches failed with error: ' +
                                      str(e) + ' on branch: ' + str(branch))
                    status = (False, e)
                    return status

            chdir(cwd)
            status = (True, branches)
        except Exception as e:  # pragma: no cover
            self.logger.error('repo_branches failed with error: ' + str(e))
            status = (False, e)

        return status
1308799
def get_branches(path):
    
    code, output = call(path, 'branch', '--list')
    if code > 0:
        return None
    branches = output.split('\n')
    newbr = [None]
    for br in branches:
        if br:
            if br[0] == '*':
                newbr[0] = br[2:]
            else:
                newbr.append(br[2:])
    return newbr
448354
def read_git_branch():
    """"""
    try:
        with open(CC_INIT, "r") as f:
            found = False
            while not found:
                line = f.readline().strip().split()
                try:
                    found = True if line[0] == '_git_branch' else False
                except IndexError:
                    pass
        branch = line[2].replace('"', '')
        if len(branch) == 0:
            branch = None
        return branch
    except IOError:
        return None
873667
def branches(config, searchstring=""):
    """"""
    repo = config.repo

    branches_ = list(find(repo, searchstring))
    if branches_:
        merged = get_merged_branches(repo)
        info_out("Found existing branches...")
        print_list(branches_, merged)
        if len(branches_) == 1 and searchstring:
            # If the found branch is the current one, error
            active_branch = repo.active_branch
            if active_branch == branches_[0]:
                error_out("You're already on '{}'".format(branches_[0].name))
            branch_name = branches_[0].name
            if len(branch_name) > 50:
                branch_name = branch_name[:47] + "…"
            check_it_out = (
                input("Check out '{}'? [Y/n] ".format(branch_name)).lower().strip()
                != "n"
            )
            if check_it_out:
                branches_[0].checkout()
    elif searchstring:
        error_out("Found no branches matching '{}'.".format(searchstring))
    else:
        error_out("Found no branches.")
1128429
def branches(self):
        # type: () -> List[str]
        
        if self._branches is None:
            cmd = 'git branch --contains {}'.format(self.sha1)
            out = shell.run(
                cmd,
                capture=True,
                never_pretend=True
            ).stdout.strip()
            self._branches = [x.strip('* \t\n') for x in out.splitlines()]

        return self._branches
267546
def branch(self):
        
        branch = [self]
        for c in self.children:
            branch += c.branch()
        return branch
1331739
def branches(self):
        
        for branch in self._grid.graph_edges():
            if branch['branch'].ring == self:
                yield branch
450582
def branch(self, name):
        
        json = None
        if name:
            url = self._build_url('branches', name, base_url=self._api)
            json = self._json(self._get(url), 200)
        return Branch(json, self) if json else None
1086571
def get_branches(self, repo_slug=None):
        
        repo_slug = repo_slug or self.repo_slug or ''
        url = self.url('GET_BRANCHES',
                       username=self.username,
                       repo_slug=repo_slug)
        return self.dispatch('GET', url, auth=self.auth)
603546
def branch(self, branch_name, start_point='HEAD', force=True,
               checkout=False):
        
        return git_branch(
            self.repo_dir, branch_name, start_point, force=force,
            checkout=checkout)
351750
def get_branch():
    
    proc = Process("git status", ["git", "status"])

    try:
        while True:
            raw_line = proc.stdout.pop()
            line = raw_line.decode('utf8').strip()
            if line.startswith("On branch "):
                return line[10:]
    finally:
        try:
            proc.join()
        except Exception:
            pass
140022
def branches(self):
        """"""
        result = self.git(self.default + ['branch', '-a', '--no-color'])
        return [l.strip(' *\n') for l in result.split('\n') if l.strip(' *\n')]