def unquote(s: str):
    """Git can return quoted file names, unquote them. Always return a str."""
    if not (s[0] == '"' and s[-1] == '"'):
        # Unquoted strings are always safe, no need to mess with them
        return s

    # The string will be of the form `"<escaped>"`, where <escaped> is a
    # backslash-escaped representation of the name of the file.
    # Examples:  "with\ttwo\ttabs" , "\303\261aca-utf8", "\361aca-latin1"

    # Get rid of the quotes, we never want them in the output.
    s = s[1:-1]

    # Un-escape the backslashes.
    # latin1 is ok to use here because in Python it just maps the code points
    # 0-255 to the bytes 0x-0xff, which is what we expect.
    s = s.encode("latin1").decode("unicode-escape")

    # Convert to utf8.
    s = s.encode("latin1").decode("utf8", errors="backslashreplace")

    return s