Returns the filename for the original file that was changed in a diff part.

def get_old_filename(diff_part):
    """
    Returns the filename for the original file that was changed in a diff part.
    """
    regexps = (
        # e.g. "+++ a/foo/bar"
        r'^--- a/(.*)',
        # e.g. "+++ /dev/null"
        r'^\-\-\- (.*)',
    )
    for regexp in regexps:
        r = re.compile(regexp, re.MULTILINE)
        match = r.search(diff_part)
        if match is not None:
            return match.groups()[0]
    raise MalformedGitDiff("No old filename in diff part found.  "
                           "Examined diff part: {}".format(diff_part))