# Buggy code
def nearest_branch(self, branch, default="master"):
    # type: (str, str) -> str
    """
    Find the nearest commit in current branch history that exists
    on a different branch and return that branch name.

    We filter these branches through a list of known ancestors which have
    an initial branch point with current branch, and pick the first one
    that matches both.

    If no such branch is found, returns the given default ("master" if not
    specified).

    Solution snagged from:
    http://stackoverflow.com/a/17843908/484127
    http://stackoverflow.com/questions/1527234
    """
    try:
        relatives = self.branch_relatives(branch)
    except GitSavvyError:
        return default

    if not relatives:
        util.debug.add_to_log(
            "nearest_branch: No relatives found. Possibly on a root branch!"
        )
        return default

    util.debug.add_to_log(
        "nearest_branch: found {} relatives: {}".format(len(relatives), relatives)
    )

    return relatives[0]


# Traceback (ValueError)
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 1052, in run_
return self.run()
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/core/interfaces/rebase.py", line 48, in run
RebaseInterface(repo_path=self.repo_path)
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/core/interfaces/rebase.py", line 134, in __init__
super().__init__(*args, **kwargs)
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/common/ui.py", line 87, in __init__
self.create_view(repo_path)
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/common/ui.py", line 115, in create_view
self.render()
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/common/ui.py", line 131, in render
rendered = self._render_template()
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/common/ui.py", line 149, in _render_template
keyed_content = self.get_keyed_content()
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/common/ui.py", line 187, in get_keyed_content
for key, render_fn in self.partials.items()
File "./python3.3/collections/__init__.py", line 56, in __init__
File "./python3.3/collections/abc.py", line 578, in update
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/common/ui.py", line 187, in <genexpr>
for key, render_fn in self.partials.items()
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/core/interfaces/rebase.py", line 200, in render_diverged_commits
start=self.base_commit(),
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/core/interfaces/rebase.py", line 356, in base_commit
base_ref = self.base_ref()
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/core/interfaces/rebase.py", line 329, in base_ref
default=remote_branch or "master")
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/core/git_mixins/rebase.py", line 60, in nearest_branch
relatives = self.branch_relatives(branch)
File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/GitSavvy/core/git_mixins/rebase.py", line 23, in branch_relatives
prelude, body = re.split(r'^-+$', output, flags=re.M)
ValueError: need more than 1 value to unpack

# Fixed code
def nearest_branch(self, branch, default="master"):
    # type: (str, str) -> str
    """
    Find the nearest commit in current branch history that exists
    on a different branch and return that branch name.

    If no such branch is found, return the given default ("master" if not
    specified).

    """
    relatives = self.branch_relatives(branch)
    if not relatives:
        return default

    return relatives[0]