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

Add the ability to set the filename's used for create_patch and merge #2

Open
bmwill opened this issue Jul 1, 2020 · 3 comments
Open

Comments

@bmwill
Copy link
Owner

bmwill commented Jul 1, 2020

Right now users are unable to set their own filenames, which appear when displaying a patch or when a merge has conflicts. There should be some interface which makes it easy for user's to overwrite the currently used defaults. A few options include:

  1. Adding the ability to set the names via an option in DiffOptions and MergeOptions
  2. Introduce a new thin wrapper File which is a tuple (filename, contents) which are passed into the create_patch and merge methods instead of just passing in their contents.
@sunshowers
Copy link

sunshowers commented Dec 23, 2020

I was looking at implementing this because I'd like it in guppy, and I'm wondering whether we need to treat filenames slightly differently than we do not. I did some investigation and it looks like git diff escapes filenames that aren't UTF-8. On Linux (tested on zsh):

git init
touch foobar$'\224'
git add .
git diff --cached

prints

diff --git "a/foobar\224" "b/foobar\224"
new file mode 100644
index 0000000..e69de29

Think maybe we should do the same thing, unless there's another use case I might be missing.

@sunshowers
Copy link

Ah nvm:

git -c "core.quotePath=false" diff --cached

prints filenames without escaping them. Oh well.

rjuju added a commit to rjuju/diffy that referenced this issue Jul 11, 2021
@kpcyrd
Copy link

kpcyrd commented Apr 15, 2024

I was wondering the same, Patch::new does pretty much what I need but isn't public.

For other people running into this issue, there's a crate that can be used in the meantime: https://crates.io/crates/diffy-fork-filenames

eyakubovich pushed a commit to eyakubovich/diffy that referenced this issue Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants