def load_refs(self):
        self.refs = {}
        self.branches = {}
        self.remote_branches = {}
        self.tags = {}

        # HEAD, current branch
        self.head = self.run_cmd(['rev-parse', 'HEAD']).strip()
        self.current_branch = None
        try:
            f = open(os.path.join(self.dir, '.git', 'HEAD'))
            head = f.read().strip()
            f.close()

            if head.startswith('ref: refs/heads/'):
                self.current_branch = head[16:]
        except __HOLE__:
            pass

        # Main module references
        if self.parent:
            self.main_ref = self.parent.get_submodule_version(self.name, 'HEAD')
            if os.path.exists(os.path.join(self.parent.dir, '.git', 'MERGE_HEAD')):
                self.main_merge_ref = self.parent.get_submodule_version(self.name, 'MERGE_HEAD')
            else:
                self.main_merge_ref = None
        else:
            self.main_ref = None
            self.main_merge_ref = None

        # References
        for line in self.run_cmd(['show-ref']).split('\n'):
            commit_id, _, refname = line.partition(' ')
            self.refs[refname] = commit_id

            if refname.startswith('refs/heads/'):
                branchname = refname[11:]
                self.branches[branchname] = commit_id
            elif refname.startswith('refs/remotes/'):
                branchname = refname[13:]
                self.remote_branches[branchname] = commit_id
            elif refname.startswith('refs/tags/'):
                # Load the referenced commit for tags
                tagname = refname[10:]
                try:
                    self.tags[tagname] = self.run_cmd(['rev-parse', '%s^{commit}' % refname], raise_error=True).strip()
                except GitError:
                    pass

        # Inverse reference hashes
        self.refs_by_sha1 = invert_hash(self.refs)
        self.branches_by_sha1 = invert_hash(self.branches)
        self.remote_branches_by_sha1 = invert_hash(self.remote_branches)
        self.tags_by_sha1 = invert_hash(self.tags)
dataset/ETHPy150Open gyim/stupidgit/stupidgit_gui/git.py/Repository.load_refs