Skip to content

patch dependency does not properly support diffs generated by git #66

@NeuralModder

Description

@NeuralModder

The crate this program relies on to parse diffs:

Which, I guess, is understandable considering that none of this is part of the Unified Format specification.

A feature to strip the file path prefixes from git diffs is already present, but these issues persist. Some options to fix this:

  • Preprocess the diff similarly to how it's done for stripping the file path prefixes. For this, you'd have to: 1. remove all \ No newline at end of file lines for git diffs, 2. replace rename from and rename to lines with respective hunks for adding and removing all the lines from each of the files (not sure if this will properly remove the old files?) for git diffs, and 3. add a new PatchSource variant called GitMailbox or something, which does everything that GithubPrDiff does (which could use a rename to just GitDiff or something btw) in addition to removing, from a given patch file, all lines before the diff --git one, and the last three lines respectively containing --, the version of git used to generate the patch, and nothing.
  • Fork the upstream crate, call it gitpatch or something, and add proper support for all of this stuff. (You could probably remove the PatchSource thing altogether if you add proper autodetection for these kinds of diffs) Not sure if the upstream person will respond to any PRs, or if they care to add this sort of thing.
  • Just don't fix it and add a note to the readme to use diff -u instead of git. Which I would recommend against as most people will probably want to use git diffs, but, not my crate. I guess you could also not add support for git format-patch diffs but fix the other stuff, though those kinds of diffs are what I'm more interested in personally.

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