Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NeuralModder opened this issue Jun 30, 2024 · 0 comments
Open

Comments

@NeuralModder
Copy link

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant