Returns the names of all branches containing the given commit.

 @param commit_ref [String] git tree ref that resolves to a commit
 @return [Array<String>] list of branches containing the given commit
964924
def branches_containing_commit(commit_ref)
      `git branch --column=dense --contains #{commit_ref}`.
        sub(/\((HEAD )?detached (from|at) .*?\)/, ''). # ignore detached HEAD
        split(/\s+/).
        reject { |s| s.empty? || s == '*' }
    end
298628
def refs(self):
        
        out_refs = IterableList(RemoteReference._id_attribute_, "%s/" % self.name)
        out_refs.extend(RemoteReference.list_items(self.repo, remote=self.name))
        return out_refs
1165866
public function branches()
    {
        if (null === $this->branches) {
            $retval = $this->execute('ls-remote', array('--heads' => true, $this->getUrl()));

            if ('' === trim($retval)) {
                return $this->branches = array();
            }

            $list = explode("\n", rtrim($retval));

            $branches = array();
            foreach ($list as $line) {
                list ($hash, $ref) = explode("\t", $line);
                $branches[] = new Reference(str_replace('refs/heads/', '', $ref), Reference::BRANCH, $hash);
            }

            $this->branches = $branches;
        }

        return $this->branches;
    }
1054559
def get_commits
      log = execute(git_cmd('log', '--notes=tinyci*', '--format=%H %ct %N§§§', '--reverse'))
      lines = log.split("§§§")
      
      lines.map {|l| format_commit_data(l)}.select {|c| c[:result].nil?}
    end
588898
def branches(self):
		
		if self.github.get_rate_limit().rate.limit == 0:
			raise GithubException

		branches = self.repo.get_branches()
		return [x.name for x in branches]
1253342
def branches(self):
        

        # first pull the local branches
        local_branches = self.repo.branches
        data = [[x.name, True] for x in list(local_branches)]

        # then the remotes
        remote_branches = self.repo.git.branch(all=True).split('\n')
        if sys.version_info.major == 2:
            remote_branches = set([x.split('/')[-1] for x in remote_branches if 'remotes' in x])
        else:
            remote_branches = {x.split('/')[-1] for x in remote_branches if 'remotes' in x}

        data += [[x, False] for x in remote_branches]

        df = DataFrame(data, columns=['branch', 'local'])
        df['repository'] = self._repo_name()

        return df
1081776
def diff_objects(self, latest_commit_sha):
        
        base = ['git', '--bare', '--git-dir', self.git_path]

        object_shas = []
        summary = {'commits': [], 'trees': [], 'files': []}

        def read_parents_and_tree_from(commit):
            if commit in self.synced_object_shas or commit in object_shas:
                # this commit has already been synced or read
                return None, None

            self.synced_object_shas[commit] = True
            summary['commits'].append(commit)
            object_shas.append(commit)

            object_content = subprocess.check_output(base + ['cat-file', '-p', commit]).decode('utf-8').strip()
            parents = []
            tree = ''
            for line in object_content.splitlines():
                if line.startswith('tree '):
                    tree = line[len('tree '):]
                if line.startswith('parent '):
                    parents.append(line[len('parent '):])

            return parents, tree

        def collect_files_from_tree(tree):
            if tree in self.synced_object_shas or tree in object_shas:
                # we have exactly this tree already synced or read, meaning all its objects as well
                return

            self.synced_object_shas[tree] = True
            summary['trees'].append(tree)
            object_shas.append(tree)

            object_content = subprocess.check_output(base + ['ls-tree', '-r', '-t', tree]).decode('utf-8').strip()

            for line in object_content.splitlines():
                exploded = line.split(' ')

                if len(exploded) < 3:
                    sys.stderr.write("Error: Wrong line format of ls-tree for %s: %s\n" % (tree, line,))
                    sys.exit(1)

                object_to_add = str(exploded[2][:40])
                path = str(exploded[2][41:])

                if object_to_add in self.synced_object_shas or object_to_add in object_shas:
                    # have it already in the list or already synced
                    continue

                object_shas.append(object_to_add)
                self.synced_object_shas[object_to_add] = True
                summary['files'].append([object_to_add, path])

        commits_to_check = [latest_commit_sha]

        while len(commits_to_check):
            sha = commits_to_check.pop(0)
            parents, tree = read_parents_and_tree_from(sha)

            if parents:
                for parent in parents:
                    if parent not in commits_to_check:
                        commits_to_check.append(parent)

            if tree:
                collect_files_from_tree(tree)

        is_debug2() and self.logger.debug("shas_to_check %d: %s " % (len(object_shas), str(object_shas),))

        if not object_shas:
            return [], summary

        try:
            is_debug2() and self.logger.debug("Do git-cat-file-check.sh")

            ssh_stream = create_ssh_stream(read_home_config(), exit_on_failure=False)
            channel = ssh_stream.get_transport().open_session()
            channel.exec_command('git-cat-file-check.sh "%s"' % (self.model_name + '.git',))
            channel.sendall('\n'.join(object_shas))
            channel.shutdown_write()

            def readall(c):
                content = b''
                while True:
                    try:
                        chunk = c.recv(1024)
                        if chunk == b'':
                            break
                        content += chunk
                    except (KeyboardInterrupt, SystemExit):
                        return

                return content

            missing_objects = readall(channel).decode('utf-8').splitlines()
            channel.close()
            ssh_stream.close()

            # make sure we have in summary only SHAs we actually will sync
            for stype in six.iterkeys(summary):
                ids = summary[stype][:]
                for sha in ids:
                    if stype == 'files':
                        if sha[0] not in missing_objects:
                            summary[stype].remove(sha)
                    else:
                        if sha not in missing_objects:
                            summary[stype].remove(sha)

            return missing_objects, summary
        except (KeyboardInterrupt, SystemExit):
            raise
        except Exception as e:
            self.logger.error("Failed to generate diff_objects: %s" % (str(e),))
            for sha in object_shas:
                if sha in self.synced_object_shas:
                    del self.synced_object_shas[sha]
            return None, None
987683
def _get_branch(repo, name):
    '''
    
    '''
    try:
        return [x for x in _all_branches(repo) if x[0] == name][0]
    except IndexError:
        return False
1041676
def branches(self):
		
		req_message = 'https://api.bitbucket.org/1.0/repositories/' + self.reponame + '/branches'
		response_data = self._bitbucketAPIRequest(req_message)
		return response_data.keys()
1039954
def branches_containing(commit):
    """"""
    lines = run('branch --contains %s' % commit).splitlines()
    return [l.lstrip('* ') for l in lines]
1329672
@GET
    @Path("commitTree/{commitId}")
    public List<CommitTreeInfo> getCommitTree(final @PathParam("commitId") String commitId) throws Exception {
        return gitReadOperation(new GitOperation<List<CommitTreeInfo>>() {
            @Override
            public List<CommitTreeInfo> call(Git git, GitContext context) throws Exception {
                return doGetCommitTree(git, commitId);
            }
        });
    }
161478
def sort(self):
        
        self.sorted_commits = []
        if not self.commits:
            return self.sorted_commits
        prev_commit = self.commits.pop(0)
        prev_line = prev_commit.line_number
        prev_uuid = prev_commit.uuid
        for commit in self.commits:
            if (commit.uuid != prev_uuid or
                    commit.line_number != (prev_line + 1)):
                prev_commit.lines = self.line_range(prev_commit.line_number,
                                                    prev_line)
                self.sorted_commits.append(prev_commit)
                prev_commit = commit
            prev_line = commit.line_number
            prev_uuid = commit.uuid
        # Take care of last commit
        prev_commit.lines = self.line_range(prev_commit.line_number, prev_line)
        self.sorted_commits.append(prev_commit)
        return self.sorted_commits
867300
def _get_branches(self, closed=False):
        

        if self._empty:
            return {}

        def _branchtags(localrepo):
            """
            Patched version of mercurial branchtags to not return the closed
            branches

            :param localrepo: locarepository instance
            """

            bt = {}
            bt_closed = {}
            for bn, heads in localrepo.branchmap().iteritems():
                tip = heads[-1]
                if 'close' in localrepo.changelog.read(tip)[5]:
                    bt_closed[bn] = tip
                else:
                    bt[bn] = tip

            if closed:
                bt.update(bt_closed)
            return bt

        sortkey = lambda ctx: ctx[0]  # sort by name
        _branches = [(safe_unicode(n), hex(h),) for n, h in
                     _branchtags(self._repo).items()]

        return OrderedDict(sorted(_branches, key=sortkey, reverse=False))
1279929
def tree_list(ref)
      if (sha = @access.ref_to_sha(ref))
        commit = @access.commit(sha)
        tree_map_for(sha).inject([]) do |list, entry|
          next list unless @page_class.valid_page_name?(entry.name)
          list << entry.page(self, commit)
        end
      else
        []
      end
    end
61939
def rebase_all_branches(self):
        
        col_width = max(len(b.name) for b in self.branches) + 1
        if self.repo.head.is_detached:
            raise GitError("You're not currently on a branch. I'm exiting"
                           " in case you're in the middle of something.")
        original_branch = self.repo.active_branch

        with self.git.stasher() as stasher:
            for branch in self.branches:
                target = self.target_map[branch.name]

                # Print branch name
                if branch.name == original_branch.name:
                    attrs = ['bold']
                else:
                    attrs = []
                print(colored(branch.name.ljust(col_width), attrs=attrs),
                        end=' ')

                # Check, if target branch exists
                try:
                    if target.name.startswith('./'):
                        # Check, if local branch exists
                        self.git.rev_parse(target.name[2:])
                    else:
                        # Check, if remote branch exists
                        _ = target.commit

                except (ValueError, GitError):
                    # Remote branch doesn't exist!
                    print(colored('error: remote branch doesn\'t exist', 'red'))
                    self.states.append('remote branch doesn\'t exist')

                    continue

                # Get tracking branch
                if target.is_local:
                    target = find(self.repo.branches,
                                  lambda b: b.name == target.name[2:])

                # Check status and act appropriately
                if target.commit.hexsha == branch.commit.hexsha:
                    print(colored('up to date', 'green'))
                    self.states.append('up to date')

                    continue  # Do not do anything

                base = self.git.merge_base(branch.name, target.name)

                if base == target.commit.hexsha:
                    print(colored('ahead of upstream', 'cyan'))
                    self.states.append('ahead')

                    continue  # Do not do anything

                fast_fastforward = False
                if base == branch.commit.hexsha:
                    print(colored('fast-forwarding...', 'yellow'), end='')
                    self.states.append('fast-forwarding')
                    # Don't fast fast-forward the currently checked-out branch
                    fast_fastforward = (branch.name !=
                                        self.repo.active_branch.name)

                elif not self.settings['rebase.auto']:
                    print(colored('diverged', 'red'))
                    self.states.append('diverged')

                    continue  # Do not do anything
                else:
                    print(colored('rebasing', 'yellow'), end='')
                    self.states.append('rebasing')

                if self.settings['rebase.show-hashes']:
                    print(' {}..{}'.format(base[0:7],
                                           target.commit.hexsha[0:7]))
                else:
                    print()

                self.log(branch, target)
                if fast_fastforward:
                    branch.commit = target.commit
                else:
                    stasher()
                    self.git.checkout(branch.name)
                    self.git.rebase(target)

            if (self.repo.head.is_detached  # Only on Travis CI,
                    # we get a detached head after doing our rebase *confused*.
                    # Running self.repo.active_branch would fail.
                    or not self.repo.active_branch.name == original_branch.name):
                print(colored('returning to {0}'.format(original_branch.name),
                              'magenta'))
                original_branch.checkout()
63211
function getCommits(repo, branchName) {
  return caller.call(repo, repo.commits, branchName)
  .then(function (commits) {
    return commits.map(function (commitObj) {
      return {
        id: commitObj.id,
        message: commitObj.message,
        committed_date: commitObj.committed_date
      }
    })
  })
}
1176852
def local_branches
      @local_branches ||= begin
        branches = []
        if not git.branches.local.empty?
          branches << git.branches.local.select{ |b| b.current }[0].name
          branches << git.branches.local.select{ |b| not b.current }.map{ |b| b.name }
        end
        branches.flatten
      end
    end