def unstash_index(sync=False, branch=None):

    repo_check()

    stash_list = repo.git.execute([git,
        'stash', 'list'])

    if branch is None:
        branch = get_current_branch_name()

    for stash in stash_list.splitlines():

        verb = 'syncing' if sync else 'switching'

        if (
            (('Legit' in stash) and
                ('On {0}:'.format(branch) in stash) and
                (verb in stash))
            or (('GitHub' in stash) and
                ('On {0}:'.format(branch) in stash) and
                (verb in stash))
        ):
            return stash[7]
Returns an unstash index if one is available.
dataset/ETHPy150Open kennethreitz/legit/legit/scm.py/unstash_index