Skip to content

Add an option to pass over non-diff lines #12

@sourcefrog

Description

@sourcefrog

It's not uncommon for unix diffs to be embedded within text that's not part of the diff, and it's common in other tools to just skip this text.

For example https://man7.org/linux/man-pages/man1/patch.1.html:

patch tries to skip any leading garbage, apply the diff, and then skip any trailing garbage. Thus you could feed an email message containing a diff listing to patch, and it should work...

Since part of the point of this tool is to turn the patch into an AST, we could and perhaps should just return this text as part of the parsed format. That might require adding a higher level concept of "a sequence of patches with garbage between them", whereas today from_multiple just returns a Vec<Patch>. Perhaps for now it's enough to just skip the garbage. That would handle cases like #11 index ... without needing to specifically recognize it, and any other metadata potentially inserted by other VCSes or tools.

...

Actually, it seems in at least some cases but not all, it will skip garbage lines...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions