def main():
    usage = "git restack [BRANCH]"

    parser = argparse.ArgumentParser(usage=usage, description=COPYRIGHT)

    parser.add_argument("-v", "--verbose", dest="verbose", action="store_true",
                        help="Output more information about what's going on")
    parser.add_argument("--license", dest="license", action="store_true",
                        help="Print the license and exit")
    parser.add_argument("--version", action="version",
                        version='%s version %s' %
                        (os.path.split(sys.argv[0])[-1], get_version()))
    parser.add_argument("branch", nargs="?")

    parser.set_defaults(verbose=False)

    try:
        (top_dir, git_dir) = git_directories()
    except GitDirectoriesException as no_git_dir:
        pass
    else:
        no_git_dir = False
        config = Config(os.path.join(top_dir, ".gitreview"))
    options = parser.parse_args()
    if no_git_dir:
        raise no_git_dir

    if options.license:
        print(COPYRIGHT)
        sys.exit(0)

    global VERBOSE
    VERBOSE = options.verbose

    if options.branch is None:
        branch = config['branch']
    else:
        branch = options.branch

    if branch is None:
        branch = 'master'

    status = 0

    cmd = "git merge-base HEAD origin/%s" % branch
    base = run_command_exc(GitMergeBaseException, cmd)

    run_command_foreground("git rebase -i %s" % base, stdin=sys.stdin)

    sys.exit(status)
dataset/ETHPy150Open openstack-infra/git-restack/git_restack/cmd.py/main/original