def get_new_filename(diff_part):
    """
    Returns the filename for the updated file in a diff part.
    """
    regexps = (
        # e.g. "+++ b/foo/bar"
        r'^\+\+\+ b/(.*)',
        # 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 new filename in diff part found.  "
                           "Examined diff part: {}".format(diff_part))
Returns the filename for the updated file in a diff part.